题目大意:关于acm竞赛排名的题目,对于参赛者首先按做出的题目排名,然后是罚时,最后是编号。

  多关键字域排序问题。

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cctype>
 4 #include <iostream>
 5 #include <algorithm>
 6 using namespace std;
 7
 8 struct Cont
 9 {
10     int id, num, t_penalty;
11     int penalty[10];
12     bool solved[10], join;
13     bool operator < (const Cont & c) const
14     {
15         if (num != c.num)  return num > c.num;
16         if (t_penalty != c.t_penalty)  return t_penalty < c.t_penalty;
17         return id < c.id;
18     }
19 } cont[110];
20
21 int main()
22 {
23 #ifdef LOCAL
24     freopen("in", "r", stdin);
25 #endif
26     int T;
27     scanf("%d", &T);
28     getchar();
29     char str[100];
30     gets(str);
31     while (T--)
32     {
33         memset(cont, 0, sizeof(cont));
34         for (int i = 1; i <= 100; i++)
35             cont[i].id = i;
36         while (gets(str) && str[0])
37         {
38             int c, p, time;
39             char ch;
40             sscanf(str, "%d%d%d", &c, &p, &time);
41             for (int i = strlen(str)-1; i >= 0; i++)
42                 if (isupper(str[i]))
43                 {
44                     ch = str[i];
45                     break;
46                 }
47             cont[c].join = true;
48             if (ch == 'C')
49             {
50                 if (!cont[c].solved[p])
51                 {
52                     cont[c].num++;
53                     cont[c].penalty[p] += time;
54                     cont[c].solved[p] = true;
55                 }
56             }
57             else if (ch == 'I')
58             {
59                 if (!cont[c].solved[p])
60                     cont[c].penalty[p] += 20;
61             }
62         }
63         for (int i = 1; i <= 100; i++)
64             for (int j = 1; j <= 9; j++)
65                 if (cont[i].solved[j])
66                     cont[i].t_penalty += cont[i].penalty[j];
67         sort(cont+1, cont+101);
68         for (int i = 1; i <= 100; i++)
69             if (cont[i].join)
70                 printf("%d %d %d\n", cont[i].id, cont[i].num, cont[i].t_penalty);
71         if (T)  printf("\n");
72     }
73     return 0;
74 }

View Code

  要注意的是,当一道题目正确提交后,以后对该题目的提交都对结果无影响。一直注意这点了,却忘了当一道题最终没有正确提交时,以前的错误提交是不计算罚时的,因为这个纠结了好长时间,WA的好惨...看别人代码时心里还在想“干嘛多次一举保存每个题的罚时?”,忽然就明白了,是我错了...

转载于:https://www.cnblogs.com/xiaobaibuhei/p/3297740.html

UVa 10258 - Contest Scoreboard相关推荐

  1. UVA10258 ZOJ1837 Contest Scoreboard【结构排序】

    Contest Scoreboard Time Limit: 2 Seconds Memory Limit: 65536 KB Think the contest score boards are w ...

  2. sicily题目分类

    sicily题目分类 1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 11. ...

  3. [sicily]部分题目分类

    sicily题目分类 1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 11. ...

  4. Sicily 题目分类

    依照自己水平挑着做→ →~~ 1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 ...

  5. 编程题目分类(剪辑)

    1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 11. 模拟 12. 算术与代 ...

  6. UVa Online Judge 工具網站

    UVa Online Judge 工具網站 转自http://www.csie.ntnu.edu.tw/~u91029/uva.html Lucky貓的ACM園地,Lucky貓的 ACM 中譯題目 M ...

  7. (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO

    下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...

  8. 算法竞赛入门经典+挑战编程+USACO

    下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...

  9. ACMer Training 学习指导

    本文原地址 一.UVaOJ http://uva.onlinejudge.org 西班牙Valladolid大学的程序在线评测系统,是历史最悠久.最著名的OJ. 二.<算法竞赛入门经典> ...

最新文章

  1. 19. 删除链表的倒数第N个节点
  2. SQLSERVER查看sql语句的执行时间
  3. 网站权重增加需要做的
  4. 李永乐线性代数2020年强化课手写笔记汇总
  5. Java通过HighCharts导出图表
  6. java启动mysq服务_Java Web开发——MySQL数据库的安装与配置
  7. php打开文件读写函数,php中常用文件操作读写函数介绍
  8. 平板电脑有什么用_除了盖泡面,平板电脑没什么用了
  9. 驯服 Tiger: 并发集合
  10. python和别的脚本语言_PHP与Python与其它脚本语言
  11. android 布局可大可小,UI设计教程之:ios与android ui适配(将IOS UI转换成Android经验畅谈)...
  12. tomcat配置线程参数maxThreads、acceptCount
  13. Matlab GUI编程技巧(四):m文件与simulink之间数据传递
  14. 【原型】Axure基本入门
  15. Go适合做什么?为何这么多人偏爱Go语言?
  16. 2020 阿里、字节iOS面试题之Runtime相关问题2
  17. 关于ORACLE索引
  18. 腾讯游戏助手运行闪退日志查看
  19. 离散数学 (II) 习题 1
  20. CF1244C The Football Season

热门文章

  1. iBatis resultMap出错 The error happened while setting a property on the result object 解决办法
  2. 关于 Unloading class sun.reflect.GeneratedSerial...
  3. Spring PropertyPlaceholderConfigurer Usage - 使用系统变量替换spring配置文件中的变量
  4. goole机器学习视频链接【学习笔记】
  5. leetcode 将包含 n 个元素的数组向右旋转 k 步
  6. 什么是Intent? 转
  7. Oracle笔记 十四、查询XML操作、操作系统文件
  8. Err:query must begin with SELECT or FROM
  9. Qt OpenGL裁剪测试
  10. C#中使用JavaScriptSerializer类实现序列化与反序列化