Aizu 1315 Gift from the Goddess of Programming 解题报告
来源:互联网 发布:适用于mac的办公软件 编辑:程序博客网 时间:2024/05/21 17:34
题目
题意:
一群ACMer去祭坛祈祷,其中在God在的时候祈祷总时长最长的人会被选中……现在告诉你所有人的出入记录,并且God的编号为0,求最长的总时长。
读了好几遍,不知道是不是必须当天离开,也不知道是否保证最后全部人都会离开。
题解:
以保万一,写得很麻烦,但我觉得忽略日期是可以的。
//Memory:1220KB
//Length:1193B#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <map>using namespace std;#define MAXN 1010#define INF 1000000007map<int,int> ma;int pre[MAXN],sum[MAXN];int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};int gettime(){ int m,d,h,t; scanf("%d/%d %d:%d",&m,&d,&h,&t); return ((mon[m-1]+d)*24+h)*60+t;}int main(){ //freopen("/home/moor/Code/input","r",stdin); int n,now,ans; while(scanf("%d",&n)&&n) { now=1; ma.clear(); ma[0]=0; memset(pre,0x3f,sizeof(pre)); memset(sum,0,sizeof(sum)); for(int i=0;i<n;++i) { char s[2]; int t,p; t=gettime(),scanf("%s%d",s,&p); if(ma.find(p)==ma.end()) ma[p]=now++; p=ma[p]; if(s[0]=='I') pre[p]=t; else { if(p==0) for(int j=1;j<now;++j) sum[j]+=max(0,t-max(pre[0],pre[j])); else sum[p]+=max(0,t-max(pre[0],pre[p])); pre[p]=INF; } } ans=0; for(int i=1;i<now;++i) ans=max(ans,sum[i]); printf("%d\n",ans); }}
- Aizu 1315 Gift from the Goddess of Programming 解题报告
- Aizu 1315 Gift from the Goddess of Programming
- 解题报告 之 HDU5318 The Goddess Of The Moon
- The University of Chicago Invitational Programming Contest 2012 解题报告
- Aizu 1316 The Sorcerer's Donut 解题报告
- Excerpts from The Elements of Programming Style
- Excerpts from The Practice of Programming
- HDU 5318 The Goddess Of The Moon
- HDU 5318 The Goddess Of The Moon
- 【解题报告】hdu1010 Tempter of the Bone
- hdoj1010(temper of the bone) 解题报告
- The 11th Zhejiang University Programming Contest / 解题报告 4.3
- The 2006 Benelux Algorithm Programming Contest 解题报告
- Aizu 1173 The Balance of the World
- LeetCode解题报告--Remove Nth Node From End of List
- [LeetCode] Remove Nth Node From End of List 解题报告
- [LeetCode] Remove Nth Node From End of List 解题报告
- Remove Nth Node From End of List 解题报告
- VC中如何让子对话框响应最大化、最小化、关闭等系统消息
- 使用printascii与printhex输出log到串口
- 数据库操作
- 静态包含与动态包含的区别
- UVA301- Transportation
- Aizu 1315 Gift from the Goddess of Programming 解题报告
- Android开发权威指南(第2版)新书发布(免费下载随书光盘内容,包括Android源代码)
- 2009-03-30 16:41 Http和Socket连接区别
- 简述Linux进程间通信的几种方式
- oracle用存储过程实现分页
- java 类与 c++类异同:
- Open Source iSeries Tools (JCRCMDS)
- 09-05总结
- 4.1 E2