链接:https://ac.nowcoder.com/acm/contest/18462/H
来源:牛客网

题目描述

ICPC Regional contest results are determined by the final team standings after a regional contest. A regional contest consists of some number of problems that are to be solved by some number of teams.

Teams are ranked according to the most problems solved. Teams who solve the same number of problems are ranked by least total time. The total time is the sum of the time consumed for each problem solved. The time consumed for a solved problem is the time elapsed from the beginning of the contest to the submittal of the first accepted run plus 20 penalty minutes for every previously rejected run for that problem. There is no time consumed for a problem that is not solved. In the event of ties, the team with the smaller time consumed of the last correctly submitted solution ranks higher. That process is repeated as needed (2nd to last correctly submitted problem, 3rd to last correctly submitted problem, etc.) If there is still a tie after all tie-breakers have been exhausted, the teams are ranked equally and displayed in team number order. For example, if there are 3 teams in a contest, and teams 1 and 3 both rank 1, then team 2 would be rank 3 (there is no rank 2 in this case).

For this problem you will write a program to print the final standings of a contest based on the supplied input.

输入描述:


The first line of input contains four space separated integers that define the contest parameters: NT NP NS NR for number of teams, number of problems, number of submissions and number ofhighest rank to display respectively. (2 <= NT <= 100), (1 <= NP <= 20), (1 <= NS <= 10000), (1 <= NR <= NT). Note that it is possible that the highest ranked team(s) actually displayed could be lessthan NR.

The next NS lines each contain four space separated integers the describe submissions. Eachsubmission line has T P t D for team number, problem number, time submitted and dispositionrespectively. The time submitted is the number of minutes since the start of the contest. (1 <= T <= NT), (1 <= P <= NP), (0 <= t < 300), D = 0 or 1 as to whether the submission rejected (wrong) oraccepted (correct) respectively. The value of t will never be less than the previous line’s value for t.Any submissions with t >= 300 should be ignored.

输出描述:

The output will consist of the ranked standings (best to worst) for the contest showing all teams withrank 1 through NR . Each line will contain 16 characters grouped in four columns. The first column isthe rank left justified in a four-character field. The second column is the team number left justified ina four-character field. The third column is the number of problems solved in a right justified threecharacter field. The fourth column is the total time right justified in a five-character field.

示例1

输入

复制

50 12 45 2
16 1 2 1
50 1 5 1
3 1 5 1
16 11 8 0
16 7 10 1
3 7 11 1
50 7 11 1
16 8 14 1
3 11 16 0
3 9 24 1
50 8 27 1
16 11 29 0
50 11 39 1
16 9 41 1
3 8 42 1
50 9 50 1
3 11 52 1
3 10 56 1
16 5 62 1
16 11 72 1
3 3 75 1
50 3 77 1
16 3 103 1
3 3 132 0
3 5 138 1
16 2 147 0
16 2 155 0
16 10 169 1
16 2 188 0
16 2 197 1
50 5 232 1
3 4 253 1
50 10 270 0
50 10 270 0
50 10 270 0
50 10 270 0
50 10 270 0
50 10 270 0
50 10 270 0
50 10 270 0
50 10 270 0
50 10 270 0
50 10 270 0
3 6 299 1
50 10 299 1

输出

复制

1   3    10  975
2   16    9  770

备注:

因为可能出现rank并列的情况,最后输出的是rank<=NR的队伍。例如rank为:1 2 3 4 4 4 7 8 9,如果NR为4,则输出1 2 3 4 4 4。 
#include <time.h>
#include <cstdio>
#include <iostream>
#include <set>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
using namespace std;const int maxn = 1e5 + 9;struct info {long long fashi = 0, tishu = 0, id, rank = 0, last = 0;long long timeofti[22], fashiofti[22];bool pass[22];
}a[111];bool cmp(info x, info y) {if (x.tishu != y.tishu)return x.tishu > y.tishu;if (x.fashi != y.fashi)return x.fashi < y.fashi;if (x.last != y.last)return x.last < y.last;return x.id < y.id;
}int main() {for (int i = 0; i < 111; i++) {a[i].id = i;}int nt, np, ns, nr;cin >> nt >> np >> ns >> nr;while (ns--) {int T, p, t, d;cin >> T >> p >> t >> d;if (a[T].pass[p] == 1)continue;if (t < 300) {if (d == 1) {a[T].pass[p] = 1;a[T].tishu++;a[T].fashi += t + a[T].fashiofti[p];a[T].last = max(t + a[T].fashiofti[p], a[T].last);}else {a[T].fashiofti[p] += 20;}}}sort(a + 1, a + nt + 1, cmp);int r = 2;a[1].rank = 1;for (int i = 2; i <= nt; i++) {if (a[i].tishu != a[i - 1].tishu || a[i].fashi != a[i - 1].fashi || a[i].last != a[i - 1].last) {a[i].rank = i;}else {a[i].rank = a[i - 1].rank;}}for (int i = 1; i <= nt; i++) {if (a[i].rank <= nr)cout << left << setw(4) << a[i].rank << left << setw(4) << a[i].id << right << setw(3) << a[i].tishu << right << setw(5) << a[i].fashi << endl;else break;}return 0;
}

H ICPC Standings相关推荐

  1. 安徽科技学院 2014-2015-2学期计算机14级12班《C语言程序设计II》期末考试

    Contest - 2014-2015-2学期计算机14级12班<C语言程序设计II>期末考试 Start time:  2015-07-03 19:05:00.0  End time:  ...

  2. 2020 ICPC 南京 H Harmonious Rectangle (DFS剪枝+思维)

    题目链接H-Harmonious Rectangle_第 45 届国际大学生程序设计竞赛(ICPC)亚洲区域赛(南京) 题目描述 A vertex-colored rectangle is a rec ...

  3. 2020 ICPC沈阳站-D,H

    icpc好难啊,希望有生之年能拿牌ort..... D. Journey to Un'Goro (思维) 链接:https://codeforces.com/gym/103202/problem/D ...

  4. 2019 ICPC 南昌网络赛 H. The Nth Item

    2019 ICPC 南昌网络赛 H. The Nth Item 题目大意:已知一个数列F(n): F(0)=0,F(1)=1 F(n)=3∗F(n−1)+2∗F(n−2),(n≥2) ​ 给你一个操作 ...

  5. The 2019 ICPC Asia-East Continent Final(M、E、H、C)

    The 2019 ICPC Asia-East Continent Final 大部分学习于:The 2019 ICPC Asia-East Continent Final(部分题解) 欠了一屁股的题 ...

  6. HDU - 5875 2016 ACM/ICPC 大连网络赛 H题 暴力

    题目链接 题意:给你一个区间l,r一直将val[l]模上val[l+1],val[l+2]...val[r],因为一个模上比前一个数小数是没有意义的,所以需要将每一个点找到右边第一个小于他的点就行. ...

  7. 容斥 + 爆搜打表 ---- 2020年南京icpc H.Harmonious Rectangle

    题目链接 题目大意: 就是给你一个二维平面{(x,y)∣1≤x≤n,1≤y≤m}\{(x,y)|1\leq x\leq n,1\leq y \leq m\}{(x,y)∣1≤x≤n,1≤y≤m},你现 ...

  8. AC自动机 + 概率dp + 高斯消元 --- HDU 5955 or 2016年沈阳icpc H [AC自动机 + 概率dp + 高斯消元]详解

    题目链接 题目大意: 就是有NNN个人,每个人都会猜一个长度为LLL的只包含{1,2,3,4,5,6}\{1,2,3,4,5,6\}{1,2,3,4,5,6}的序列,现在裁判开始投掷骰子,并且把每次的 ...

  9. ICPC 徐州 H Yuuki and a problem (树状数组套主席树)

    Yuuki and a problem 先不管第一问的修改操作,考虑如何达到第二问的查询操作, 题目要我们给出一个区间[l,r][l, r][l,r]中,不能通过权值+++得到的最小的数字是什么, 假 ...

最新文章

  1. DUL 恢复简单表测试
  2. “举报”阿里巴巴 Arthas,大幅降低 OOM Trouble shooting 门槛
  3. spring(1)Spring之旅
  4. MySQL与MariaDB概述 (二)
  5. 华为荣耀v8计算机没了,华为荣耀V8真机实测 没了徕卡到底咋样?
  6. 定制简单的404和403页面
  7. Linux下从零搭建WordPress
  8. 多旋翼无人机控制之完整闭环控制设计
  9. 安装算量软件使用_鹏业安装算量软件常用按钮汇总(三)
  10. cap 2 加州房价预测
  11. Ubuntu 18.04 LTS (Bionic Beaver) 已经发布附官网下载链接
  12. 跑步时戴什么耳机好、推荐几款专业跑步的耳机
  13. 深克隆和浅克隆的区别
  14. 卧槽!一行代码让 Python 的运行速度提高100倍
  15. codeforces 2022.11.22-11.29
  16. 千牛文件已上传服务器,千牛怎样挂在云服务器上
  17. 5分钟搭建好ElasticSearch开发环境
  18. linux下安装和破解pycharm专业版
  19. 脑机接口新进展!即插即用,不用每天校准
  20. 【elasticsearch从入门到实战】完整合集版,带思维导图

热门文章

  1. 20几岁,不要急着长大
  2. 【iOS开发】-UIPickerView
  3. 总结了下PHPExcel官方读取的几个例子
  4. 【离散数学】阿贝尔群和循环群编程题
  5. 怎么培养孩子的金钱观
  6. 支付宝php支付接口说明
  7. Java中的main( )函数
  8. javascript 数组方法 slice() 的使用说明
  9. 如何解决Visual Studio编译错误,即“处理器体系结构之间的不匹配”?
  10. The 2021 ICPC Asia Shanghai Regional Programming Contest 2021ICPC上海站VP