题目链接: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. 16mysql1

    一.数据库的基本概念 1.1  常用的关系型数据库                        数据库(Database)是按照数据结构来组织.存储和管理数据的仓库. 1.2  sql语言     ...

  2. day27 多态 多继承 接口类 抽象类

    简单来说:多态就是指一个相同的方法名在不同的对象调用的时候实现一样或者不一样的方法实例1: 动物类有个方法 "嚎叫" 狗类也有个方法 "嚎叫" 猫类继承了动物类 ...

  3. 【POI每日题解 #7】TES-Intelligence Test

    题目链接 这道题第一眼看去类比BANK-Cash Dispenser 不过1e6 * 1e6 = 1e12   分分钟MLE啊 想到优化 就yy到一种近似主席树的做法 来维护类似BANK的一堆序列 开 ...

  4. 洛谷UVA12995 Farey Sequence(欧拉函数,线性筛)

    洛谷题目传送门 分数其实就是一个幌子,实际上就是求互质数对的个数(除开一个特例\((1,1)\)).因为保证了\(a<b\),所以我们把要求的东西拆开看,不就是\(\sum_{i=2}^n\ph ...

  5. 实现 60fps 的网易云音乐首页

    网易云音乐是一款很优秀的音乐软件,我也是它的忠实用户.最近在研究如何更好的开发TableView,接着我写了一个Model驱动的小框架 - MDTable.为了去验证框架的可用性,我选择了网易云音乐的 ...

  6. tf 常用函数 28原则

    一个tensorflow图由以下几部分组成: 占位符变量(Placeholder)用来改变图的输入. 模型变量(Model)将会被优化,使得模型表现得更好. 模型本质上就是一些数学函数,它根据Plac ...

  7. matplotlib 28原则

    记下各个简易模板,方便ctrl+c和ctrl+v 子图: import numpy as np import matplotlib.pyplot as plt x = np.array(range(1 ...

  8. A1016. Phone Bills

    A long-distance telephone company charges its customers by the following rules: Making a long-distan ...

  9. 笔记: c开发gui程序 (WM_CREATE, WS_CLIPCHILDREN , SetWindowPos)

    过去两年,用c写的gui程序我一般使用的套路是: 在 winMain()中, 先创建一个主窗口, 紧接着就是在下面创建子窗口(子控件). 可能是因为写这方面的程序较少,所以也没遇到什么大问题,之前就是 ...

  10. 有趣的filter

    js中的filter就是过滤的意思,比如,我们以什么样的方式进行过滤,得到我们想要的结果. 对,我们要的就是这个结果. 给定一个数组,我们要的是Burger(汉堡) const restaurants ...