hdu1084:What is your grade?
来源:互联网 发布:relex软件模块 编辑:程序博客网 时间:2024/05/24 03:07
题目地址:
http://acm.hdu.edu.cn/showproblem.php?pid=1084
这道题要注意只有一个人做4.3.2.1道题时是90.80,70,60分,因为这坑了我好久!
还有注意下排序就OK了,简直水得不能再水了!
上AC代码:
#include<iostream>#include<cmath>#include<cstdio>#include<queue>#include<iomanip>using namespace std;const int maxn = 101;struct Student{ int num; int ID; int time;}st[maxn];int ranks[4][2] = { { 65, 60 }, { 75, 70 }, { 85, 80 },{ 95, 90 } };bool cmp(const Student &s1, const Student &s2){ return s1.num > s2.num || (s1.num == s2.num&&s1.time < s2.time);}int main(){ int n, a, b, c; int T; while (cin >> T, T != -1){ int i, j,t; for (i = 0; i < T;i++){ scanf("%d %d:%d:%d", &n, &a, &b, &c); int time = a * 60 * 60 + b * 60 + c; st[i].ID = i; st[i].num = n; st[i].time = time; } sort(st, st + T, cmp); int score[maxn]; int num = 0;j=0;int end=0; int pres = -1;bool flag1=false; bool flag = false; for (i = 0; i < T; i++){ if (st[i].num == 5){ score[st[i].ID] = 100; } else if(st[i].num==0){if(flag&&!flag1){end=i;flag1=true;} score[st[i].ID] = 50; } else if(pres==st[i].num){ num++;end=i+1;flag=true; } else{if(flag){ int mid = num / 2; for (t = j; t < j+mid; t++){ score[st[t].ID] = ranks[st[t].num - 1][0]; } for (t = j + mid; t < i; t++){ score[st[t].ID] = ranks[st[t].num - 1][1]; }} num = 1; pres = st[i].num;score[st[i].ID]=ranks[st[i].num-1][1]; j = i;flag=false; } }if(flag&&j<end){int mid = num / 2;for (t = j; t < j+mid; t++){ score[st[t].ID] = ranks[st[t].num - 1][0]; } for (t = j + mid; t < end; t++){ score[st[t].ID] = ranks[st[t].num - 1][1]; }} for (i = 0; i < T; i++){ printf("%d\n", score[i]); } printf("\n"); } return 0;}
0 0
- hdu1084(What Is Your Grade?)
- HDU1084:What Is Your Grade?
- Hdu1084 What Is Your Grade?
- HDU1084--What Is Your Grade?
- hdu1084:What is your grade?
- HDU1084 What Is Your Grade?
- hdu1084 What's your grade?
- hdu1084 What Is Your Grade? 结构体的应用
- 【结构体排序】HDU1084 What Is Your Grade?
- What Is Your Grade?
- What Is Your Grade?
- What Is Your Grade?
- what is your grade
- What Is Your Grade?
- What Is Your Grade?
- HDOJ1084 What Is Your Grade?
- hd1084 What Is Your Grade?
- 十二、What Is Your Grade?
- 随想录
- oc 字符串NSString
- 第二节 c++概述(下)
- DataRow 类
- Linux中getrusage的使用
- hdu1084:What is your grade?
- 程序优化总结
- iTween-MoveTo
- 构造器
- unix编程书籍推荐
- 一个实现多线程的例子
- hibernate 注解
- cocos2d-x 3.0 版本创建新工程方法
- 如何在pcduino上实现WiFi AP功能