HDU 1177."Accepted today?"【结构体排序(水)】【1月6】
2016-01-06 01:07
537 查看
"Accepted today?"
[align=left]Problem Description[/align]
Do you remember a sentence "Accepted today?" Yes, the sentence is mentioned frequently in lcy's course "ACM Programming"!
The contest is still in progress this moment. How excited it is! You, smart programmer, must have AC some problems today. "Can I get copper medal, silver medal, or even golden medal?" Oh, ha-ha! You must be considering this question. And now, the last problem
of this contest comes.
Give you all submitting data in the contest, and tell you the number of golden medals, silver medals and copper medals; your task is to output someone's contest result.
Easy? Of course! I t is the reason that I designed the problem.
When you have completed this contest, please remember that sentence〃 Accepted today?〃兒
[align=left]Input[/align]
Input contains multiple test cases. Each test case starts with five numbers N (4 =< N <= 130 -- the total number of attendees), G, S, C (1<=G<=S<=C<N --G, S, C denoting the number of golden medals, silver medals and copper medals
respectively) and M (0<M<=N). The next N lines contain an integer P (1<=P<=8 --number of problems that have been solved by someone) and a time T(for example,"02:45:17", meaning 2 hours and 45 minutes and 17 seconds consumed according to contest rules) each.
You can assume that all submit data are different.
A test case starting with 0 0 0 0 0 terminates input and this test case should not to be processed.
[align=left]Output[/align]
For each case, print a sentence in a line, and it must be one of these sentences:
Accepted today? I've got a golden medal :)
Accepted today? I've got a silver medal :)
Accepted today? I've got a copper medal :)
Accepted today? I've got an honor mentioned :)
Note:
You will get an honor mentioned if you can't get copper medal, silver medal or golden medal.
[align=left]Sample Input[/align]
[align=left]Sample Output[/align]
模拟比赛排名,结构体排序就好。不知道这个题是怎么坑了我的`````好苦逼!
但是为什么下面的代码过不了?求大神解答!!!!
[align=left]Problem Description[/align]
Do you remember a sentence "Accepted today?" Yes, the sentence is mentioned frequently in lcy's course "ACM Programming"!
The contest is still in progress this moment. How excited it is! You, smart programmer, must have AC some problems today. "Can I get copper medal, silver medal, or even golden medal?" Oh, ha-ha! You must be considering this question. And now, the last problem
of this contest comes.
Give you all submitting data in the contest, and tell you the number of golden medals, silver medals and copper medals; your task is to output someone's contest result.
Easy? Of course! I t is the reason that I designed the problem.
When you have completed this contest, please remember that sentence〃 Accepted today?〃兒
[align=left]Input[/align]
Input contains multiple test cases. Each test case starts with five numbers N (4 =< N <= 130 -- the total number of attendees), G, S, C (1<=G<=S<=C<N --G, S, C denoting the number of golden medals, silver medals and copper medals
respectively) and M (0<M<=N). The next N lines contain an integer P (1<=P<=8 --number of problems that have been solved by someone) and a time T(for example,"02:45:17", meaning 2 hours and 45 minutes and 17 seconds consumed according to contest rules) each.
You can assume that all submit data are different.
A test case starting with 0 0 0 0 0 terminates input and this test case should not to be processed.
[align=left]Output[/align]
For each case, print a sentence in a line, and it must be one of these sentences:
Accepted today? I've got a golden medal :)
Accepted today? I've got a silver medal :)
Accepted today? I've got a copper medal :)
Accepted today? I've got an honor mentioned :)
Note:
You will get an honor mentioned if you can't get copper medal, silver medal or golden medal.
[align=left]Sample Input[/align]
10 1 2 3 6 2 02:45:17 2 02:49:01 2 03:17:58 2 03:21:29 4 07:55:48 3 04:25:42 3 06:57:39 2 02:05:02 2 02:16:45 2 02:41:37 0 0 0 0 0
[align=left]Sample Output[/align]
Accepted today? I've got a silver medal :)
模拟比赛排名,结构体排序就好。不知道这个题是怎么坑了我的`````好苦逼!
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int maxn = 150; struct ss { bool wo; int solve; int h; int m; int s; }; bool cmp(ss a, ss b) { if(a.solve > b.solve) return true; else if(a.solve == b.solve && a.h < b.h) return true; else if(a.solve == b.solve && a.h == b.h && a.m < b.m) return true; else if(a.solve == b.solve && a.h == b.h && a.m == b.m && a.s < b.s) return true; else return false; } int N, G, S, C, M; int main() { while(scanf("%d %d %d %d %d", &N, &G, &S, &C, &M) && (N+G+S+C+M)) { ss f[maxn]; for(int i = 0;i < N; ++i) f[i].wo = false; for(int i = 0;i < N; ++i) { //f[i].wo == false; scanf("%d %d:%d:%d", &f[i].solve, &f[i].h, &f[i].m, &f[i].s); if(i == M-1) f[i].wo = true; } sort(f, f+N, cmp); for(int i = 0;i < N; ++i) { if(f[i].wo != true) continue; if(i < G) cout <<"Accepted today? I've got a golden medal :)\n"; else if(i < G+S) cout <<"Accepted today? I've got a silver medal :)\n"; else if(i < G+S+C) cout<<"Accepted today? I've got a copper medal :)\n"; else cout <<"Accepted today? I've got an honor mentioned :)\n"; break; } } return 0; }
但是为什么下面的代码过不了?求大神解答!!!!
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int maxn = 150; struct ss { bool wo; int solve; int h; int m; int s; }; bool cmp(ss a, ss b) { if(a.solve > b.solve) return true; else if(a.solve == b.solve && a.h < b.h) return true; else if(a.solve == b.solve && a.h == b.h && a.m < b.m) return true; else if(a.solve == b.solve && a.h == b.h && a.m == b.m && a.s < b.s) return true; else return false; } int N, G, S, C, M; int main() { while(scanf("%d %d %d %d %d", &N, &G, &S, &C, &M) && (N+G+S+C+M)) { ss f[maxn]; //for(int i = 0;i < N; ++i) f[i].wo = false; for(int i = 0;i < N; ++i) { f[i].wo == false;//与上面的代码唯一不同的就是我把这个初始化放在了这里面!!!为什么不行?!!不懂 scanf("%d %d:%d:%d", &f[i].solve, &f[i].h, &f[i].m, &f[i].s); if(i == M-1) f[i].wo = true; } sort(f, f+N, cmp); for(int i = 0;i < N; ++i) { if(f[i].wo != true) continue; if(i < G) cout <<"Accepted today? I've got a golden medal :)\n"; else if(i < G+S) cout <<"Accepted today? I've got a silver medal :)\n"; else if(i < G+S+C) cout<<"Accepted today? I've got a copper medal :)\n"; else cout <<"Accepted today? I've got an honor mentioned :)\n"; break; } } return 0; }
相关文章推荐
- How MapReduce Works
- 静态分配和动态分配内存的区别
- IP学习
- Linux系统密钥验证(附件有实验过程和截图)
- windows 运行命令大全
- Android退出应用最优雅的方式(改进版)
- 转载的一篇关于vld的文章
- 2015年12月工作总结
- 远程链接服务器工具的使用
- linux看视频黑屏和无法调节屏幕亮度
- QStringLiteral的两篇外文解释(编译期转换成QString)
- hadoop集群搭建【伪分布式】
- 数据结构 JAVA描述(十五) 动态查找表 二叉排序树 二叉平衡树
- BigDecimal的学习
- QtInternal 之 高效使用QString(使用QLatin1String,QStringRef,QStringBuilder,QStringMatcher等相关类)
- C# 检查进程是否已经启动
- Arch Linux安装
- 操作手册
- 项目开发总结报告
- Qt探秘——谈ui文件的用法