B - Birthday Boy Gym - 102007B
题目链接: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的更多相关文章
- 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 ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
随机推荐
- [代码]--python爬虫联系--爬取成语
闲来无事,玩了个成语接龙,于是就想用python爬取下成语网站上的成语,直接上代码: #coding=utf-8 import requests from bs4 import BeautifulSo ...
- BZOJ4699 树上的最短路(最短路径+dfs序+线段树+堆+并查集)
首先一般化的将下水道和塌陷看成一个东西.注意到在从源点出发的所有需要使用某条下水道的最短路径中,该下水道只会被使用一次,该下水道第一个被访问的点相同,且只会在第一个访问的点使用该下水道.这个第一个访问 ...
- hdu 3911 Black And White (线段树 区间合并)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3911 题意: 给你一段01序列,有两个操作: 1.区间异或,2.询问区间最长的连续的1得长度 思路: ...
- CF1114D Flood Fill(DP)
题目链接:CF原网 题目大意:$n$ 个方块排成一排,第 $i$ 个颜色为 $c_i$.定义一个颜色联通块 $[l,r]$ 当且仅当 $l$ 和 $r$ 之间(包括 $l,r$)所有方块的颜色相同.现 ...
- 【uoj207】 共价大爷游长沙
http://uoj.ac/problem/207 (题目链接) 题意 给出一棵无根树,4种操作:在路径集合中加入一条路径,在路径集合中删除一条路径,删一条边加一条边,查询一条边是否被集合中所有路径经 ...
- Python文件和异常
程序和运行时数据是在内存中驻留的,涉及到数据交换的地方,通常是磁盘.网络等,因此需要IO接口. IO编程中,Stream(流)是一个很重要的概念,可以把流想象成一个水管,数据就是水管里的水,但是只能单 ...
- 【模板】Tarjan scc缩点
代码如下 #include <bits/stdc++.h> using namespace std; const int maxv=1e4+10; const int maxe=1e5+1 ...
- java:取屏幕大小(去掉任务栏的高度部分)
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); Insets screenInsets = Toolkit.getD ...
- ansible-playbook组件解析及操作全解
转载于http://www.178linux.com/7001 一.ansible-playbook介绍: playbook是由一个或多个”play”组成的列表.play的主要功能在于将事先归为一组的 ...
- 何谓SQL Server参数嗅探
大家听到"嗅探"这个词应该会觉得跟黑客肯定有关系吧,使用工具嗅探一下参数,然后截获,脱裤o(∩_∩)o . 事实上,我觉得大家太敏感了,其实这篇文章跟数据库安全没有什么关系,实际上 ...