题目链接:https://cn.vjudge.net/contest/283924#problem/B

题目大意:给你n个人的信息,让你找出一个时间,要求让你选择一天,使得这一天的前一个生日距离它最远,如果有多个一样的,有点选择10月27之后的。

AC代码:

 #include<iostream>
#include<stack>
#include<cstring>
#include<iomanip>
#include<stdio.h>
#include<algorithm>
#include<cmath>
using namespace std;
# define ll long long
# define inf 0x3f3f3f3f
# define lson l,m,rt<<
# define rson m+,r,rt<<|
const int maxn = 2e5+;
struct node
{
int m;
int d;
int day;
bool friend operator < (node t1,node t2)
{
return t1.day<t2.day;
}
} q[maxn];
char u;
char str[maxn];
int sto[maxn];
int a[maxn];
int f[]= {,,,,,,,,,,,};
int cal(int t1,int t2)
{
int ans=;
for(int i=; i<t1-; i++)
{
ans+=f[i];
}
ans+=t2;
return ans;
}
int main()
{
// freopen("data1.in","r",stdin);
int n,m,d;
scanf("%d",&n);
if(n==)
{
cin>>str;
cin>>q[].m>>u>>q[].d;
int i,tot=cal(q[].m,q[].d)-;
for( i=; i<; i++)
{
if(tot-f[i]>=)
tot-=f[i];
else
break;
}
if(tot==)
{
i--;
if(i==-)
i=;
tot=f[i];
}
printf("%02d-%02d\n",i+,tot);
return ;
}
for(int i=; i<=n; i++)
{
cin>>str;
cin>>q[i].m>>u>>q[i].d;
q[i].day=cal(q[i].m,q[i].d);
}
sort(q+,q+n+);
sto[]=-q[n].day+q[].day;
for(int i=; i<=n; i++)
{
sto[i]=q[i].day-q[i-].day;
}
int maxx=;
for(int i=; i<=n; i++)
{
maxx=max(maxx,sto[i]);
}
int num=,id;
for(int i=; i<=n; i++)
{
if(maxx==sto[i])
{
a[++num]=i;
}
}
// cout<<num<<endl;
if(num==)
{
int i,tot=sto[a[]]+q[a[]-].day-;
if(a[]==)tot=q[].day-;
tot=(tot+)%;
for(i=; i<; i++)
{
if(tot-f[i]>=)
tot-=f[i];
else
break;
}
if(tot==)
{
i--;
if(i==-)
i=;
tot=f[i];
}
printf("%02d-%02d\n",i+,tot);
}
else
{
int flag=;
int minn1=inf;
int minn2=inf;
int pos;
for(int i=; i<=num; i++)
{
int tmp=sto[a[i]]+q[a[i]-].day-;
if(tmp>)
tmp-=;
if(tmp>cal(,))
{
if(tmp-cal(,)<minn1)
{
minn1=tmp-cal(,);
flag=i;
}
}
else
{
if((tmp-cal(,))<minn2)
{
minn2=tmp-cal(,);
pos=i;
}
}
}
// cout<<minn1<<endl;
int i,tot;
if(minn1!=inf)
{
i,tot=sto[a[flag]]+q[a[flag]-].day-;
tot=(tot+)%;
for( i=; i<; i++)
{
if(tot-f[i]>=)
tot-=f[i];
else
break;
}
}
else
{
tot=q[pos].day-;
tot=(tot+)%;
for( i=; i<; i++)
{
if(tot-f[i]>=)
tot-=f[i];
else
break;
}
}
if(tot==)
{
i--;
if(i==-)
i=;
tot=f[i];
}
printf("%02d-%02d\n",i+,tot);
}
return ;
}

B - Birthday Boy Gym - 102007B的更多相关文章

  1. ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力

     Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS     Memory Limit:65536KB     64bit IO Fo ...

  2. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  3. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  4. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  5. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  6. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  7. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

  8. Gym 101102D---Rectangles(单调栈)

    题目链接 http://codeforces.com/gym/101102/problem/D problem  description Given an R×C grid with each cel ...

  9. Gym 101102C---Bored Judge(区间最大值)

    题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...

随机推荐

  1. 工作流管库的bpmn部署在数据库中

    工作流管库的bpmn部署在数据库中 DB_schema_update_false  没有表则创建 有表则报错 DB_SCHEMA_UPDATE_TRUE 没有表则创建 有表则不创建 脚本更新则更新数据 ...

  2. python系列-3 pyenv的使用

    安装: git clone https://github.com/yyuu/pyenv.git ~/.pyenv echo 'export PYENV_ROOT="$HOME/.pyenv& ...

  3. 【Linux】MGR部署脚本

    脚本没有完善,现在只有上半部分的基础环境搭建 [准备条件] 1.三个节点的防火墙关闭 2.原有mysql卸载删除 3.文件夹名字: mgr 所有的源码包都放在mgr的文件夹下 4.文件位置: /roo ...

  4. P2157 [SDOI2009]学校食堂

    题目描述 小F 的学校在城市的一个偏僻角落,所有学生都只好在学校吃饭.学校有一个食堂,虽然简陋,但食堂大厨总能做出让同学们满意的菜肴.当然,不同的人口味也不一定相同,但每个人的口味都可以用一个非负整数 ...

  5. 【AGC005F】Many Easy Problems (NTT)

    Description ​ 给你一棵\(~n~\)个点的树和一个整数\(~k~\).设为\(~S~\)为树上某些点的集合,定义\(~f(S)~\)为最小的包含\(~S~\)的联通子图的大小.\(~n~ ...

  6. springmvc源码解析MvcNamespaceHandler之<mvc:view-resolvers>

    说在前面 本次主要介绍springmvc配置解析. springmvc配置解析 本次介绍MvcNamespaceHandler. 进入到这个方法org.springframework.web.serv ...

  7. 配置AD RMS及SharePoint 2013 IRM问题解决及相关资源

    最近配置AD RMS及SharePoint 2013 IRM遇到几个问题: 1. RMS配置好后,client端连不上, 一直要求输入用户名和密码. 后来换了台不是SP的机器,并用内部DB,搞定.   ...

  8. 上传大数据到SharePoint 2010

    今天终于把近5G的数据上传到了SharePoint2010站点上,上传过程中发现几个要注意的问题: 1. 用360浏览器打开SP 2010站点,发现在workspace同步和windows explo ...

  9. 【AGC016E】Poor Turkeys

    Description 有\(n\)(\(1 \le n \le 400\))只鸡,接下来按顺序进行\(m\)(\(1 \le m \le 10^5\))次操作.每次操作涉及两只鸡,如果都存在则随意拿 ...

  10. luogu1984 烧水问题 (找规律)

    为了节省能量,我们会希望一个已经烧开了的水温度越低越好 那么可以得到结论,它要依次去碰当前温度从大到小的水 然后再把温度最高的烧开呗 可是直接模拟会T 稍微写一写大概能找到每次烧开花费能量的一个规律 ...