Aizu 1315 Gift from the Goddess of Programming
来源:互联网 发布:vue组件引用js插件 编辑:程序博客网 时间:2024/06/11 05:54
题目链接:Aizu 1315 Gift from the Goddess of Programming
我是一个一个人模拟的,以为会超时,没想到0ms。。
可能有更好的办法吧。
#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int MAX_N = 1000 + 10;struct S{ int id, time; char str[3];};int n;S s[MAX_N];int in_time;int main(){ while(scanf("%d", &n), n) { int y, m, h, mm, id, max_id = 0; char str[3]; for(int i = 0; i < n; i++) { scanf("%d/%d %d:%d %s %d", &y, &m, &h, &mm, str, &id); s[i].id = id, s[i].time = h * 60 + mm, strcpy(s[i].str, str); max_id = max(max_id, id); } bool is_at1, is_at2; is_at1 = is_at2 = false; int _beg_time, temp_time, max_time; max_time = temp_time = 0; _beg_time = -1; for(int j = 1; j <= max_id; j++) { for(int i = 0; i < n; i++) { if(s[i].id == 0) { if(s[i].str[0] == 'I') { is_at1 = true; if(is_at2 == true) _beg_time = s[i].time; } else { is_at1 = false; if(is_at2 == true) { if(_beg_time != -1) { temp_time += s[i].time - _beg_time; _beg_time = -1; } } } } else { if(s[i].id == j) { if(s[i].str[0] == 'I') { is_at2 = true; if(is_at1 == true) _beg_time = s[i].time; } else { is_at2 = false; if(_beg_time != -1) { temp_time += s[i].time - _beg_time; _beg_time = -1; } } } } } max_time = max(max_time, temp_time); _beg_time = -1; temp_time = 0; } printf("%d\n", max_time); } return 0;}
0 0
- Aizu 1315 Gift from the Goddess of Programming 解题报告
- Aizu 1315 Gift from the Goddess of Programming
- 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
- Aizu 1173 The Balance of the World
- hdu 5318 The Goddess Of The Moon 矩阵快速幂
- HDOJ 5318 The Goddess Of The Moon 矩阵快速幂
- hdu 5318 The Goddess Of The Moon 【矩阵快速幂】
- HDU 5318 The Goddess Of The Moon (矩阵快速幂)
- uva5318 The Goddess Of The Moon dp+矩阵快速幂
- 解题报告 之 HDU5318 The Goddess Of The Moon
- hdu5318 The Goddess Of The Moon(dp+矩阵)
- hdu5318 The Goddess Of The Moon【矩阵快速幂】
- LightOJ 1328 A Gift from the Setter
- hdu5318The Goddess Of The Moon 矩阵快速幂
- The Tao of Programming
- 挑战程序设计竞赛 2.1迷宫的最短路径
- Java中仿照C#代理
- 命名管道进程通信
- The 14th Zhejiang University Programming Contest(未完工)
- A20 文件系统预装APK
- Aizu 1315 Gift from the Goddess of Programming
- linux下多个节点ssh互相免密码连接详解
- NYOJ_14会场安排问题(不相交区间)
- DB2创建表 主键自增长
- Android学习之 有关图片缓存问提的代码封装<一>
- php乱码问题说明
- 编写一个简单的windows服务
- 网络流模板大全
- ZOJ 3519 Who is the Smartest Man(贪心)