【hdu 2093】 考试排名
来源:互联网 发布:汉王光学识别软件 编辑:程序博客网 时间:2024/05/16 23:54
思路
读入比较麻烦,用类似读入优化的办法,读进数来以后,用结构体排序。
代码
#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>using namespace std;struct node{ char name[101]; int ac, time; node(){ac = 0, time = 0;} bool operator < (const node &a)const{ return ac == a.ac ? time < a.time : ac > a.ac; }};node tt[10010];int n, p, cnt, ct, let;char ch[1010];inline int getint(){ char c; int ok = 0, num = 0, op = 1; if(ct >= let) return 0; while((c = ch[++ct]) || 1){ if(c == '-') op = -1; else if(c <= '9' && c >= '0') ok = 1, num = num*10 + c - '0'; else if(ok || c == '\0') return op*num; }}int main(){ scanf("%d%d", &n, &p); while(1){ if(scanf("%s", tt[++cnt].name+1) == EOF){ cnt --; break; } int ac = 0, time1 = 0; for(int i = 1; i <= n; i ++){ scanf("%s", ch+1), ct = 0; let = strlen(ch+1); int t = getint(), ttt; if(t <= 0) continue; if(t > 0){ ac ++; ttt = getint(); time1 += (ttt*p+t); } // else time1 += (-1*t*p); } tt[cnt].ac = ac; tt[cnt].time = time1; } sort(tt+1, tt+1+cnt); for(int i = 1; i <= cnt; i ++){ printf("%-10s %2d %4d\n", tt[i].name+1, tt[i].ac, tt[i].time); } return 0;}
0 0
- hdu 2093 考试排名
- HDU 2093 - 考试排名
- HDU 2093 考试排名
- HDU 2093 考试排名
- hdu 2093 考试排名
- HDU 2093 考试排名
- HDU 2093 考试排名
- hdu 2093 考试排名
- hdu 2093 考试排名
- HDU 2093考试排名
- hdu---2093考试排名
- HDU考试排名2093
- 【HDU 2093】考试排名
- HDU 2093 考试排名
- hdu 2093 考试排名
- 【hdu 2093】 考试排名
- HDU 2093 考试排名
- HDU 2093 考试排名
- 【各大OJ】diver(才不是driver!!!)
- 《Guava学习笔记之二》:新集合类型
- c++primer第五章语句小结-5
- 27. Remove Element(移除数组中与指定值相等的元素)
- 使用PYTHON发送电子邮件
- 【hdu 2093】 考试排名
- 94. Binary Tree Inorder Traversal
- MFC中的Create();函数
- Storm 1.0.x 运行环境的安装
- MFC CString转化为char*
- hibernate中的与数据库操作的那些事儿
- 第9周 项目2-对称矩阵的加法和乘法
- Solr-----4、Solr添加IK中文分词器
- 将[1,n^2]区间内n^2个数字分别填充到n*n的矩阵里,要求任意两个相邻的数字的和,它们的最大值最小是多少?