Kattis - Association for Computing Machinery
Posted tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Kattis - Association for Computing Machinery相关的知识,希望对你有一定的参考价值。
Association for Computing Machinery
ACM (Association for Computing Machinery) organizes the International Collegiate Programming Contest (ICPC) worldwide every year.
In the ICPC, a team of three students is presented with a problem set that contains NN problems1 of varying types and difficulty levels. The teams are not told which problems are easier (or harder). As there is only one single computer per team, each team has to decide which one of the N!N! possible problem solving orders that the team wants to use. This is called the “contest strategy” and teams who are expecting to do well in an ICPC should use the optimal contest strategy for their team.
However, when a contest has ‘First to Solve Problem [‘A’/‘B’/.../‘A’+(N−1)+(N−1)] award’ – like this ICPC SG Regional Contest 15 – sponsored by Kattis, then some of the teams may throw the optimal contest strategy out of the window in order to grab the (smaller) award.
Input
The input describes a hypothetical scenario of a 300300 minute contest.
The first line contains two non-negative integers 2≤N≤132≤N≤13 and 0≤p≤N−10≤p≤N−1. The integer NN describes the number of problems in the problem set of this ACM ICPC and the integer pp is a 0-based index that describes the problem id that your team wants to solve first before attempting the other N−1N−1 problems.
The next line contains NN integers in the range between 11 and 999999, inclusive. Each integer ii describes the estimated number of minutes to solve problem id ii according to your team. You have discussed with your team mates that your team will not put the same estimation for two different problems, so there is no ambiguity.
As an ACM ICPC duration is 55 hours, or 300300 minutes, any estimation of strictly larger than 300300 minutes for a certain problem jj basically says that you estimate that your team cannot solve problem jj during contest time.
In this problem, you can assume that all your team’s estimations are perfectly accurate, i.e. if your team estimates that your team needs 3030 minutes to solve problem kk, 270270 minutes to solve another problem ll, and have no idea how to solve the rest, and decides to solve problem kk first followed by ll, then after 3030 minutes have elapsed from the start of contest, your team really gets an ‘Accepted’ verdict from Kattis for problem kk, immediately switches to problem ll for the next 270270 minutes, gets another ‘Accepted’ verdict from Kattis for problem ll at exactly 300300 minutes (in this problem, submission at minute 300300 is a valid submission2). Thus you have 22 Accepted problems and the total penalty time of 30+300=33030+300=330 minutes as per the ICPC rules.
Output
Print two integers Num_ACNum_AC and Penalty_TimePenalty_Time separated by a single space in one line.
Num_ACNum_AC is the highest number of problems that your team can solve and Penalty_TimePenalty_Time is the lowest penalty minutes that your team can get in order to solve Num_ACNum_AC problems in this 300300 minutes ACM ICPC if your team insists to solve problem pp first from the start of the contest and then use the remaining time to work on the other N−1N−1 problems.
For the example scenario above, if your team decides to solve problem ll first followed by kk, then your team still solves Num_AC=2Num_AC=2 Accepted problems, but with the total penalty of 270+300=570270+300=570 minutes.
Sample Input 1 | Sample Output 1 |
---|---|
7 0 30 270 995 996 997 998 999 |
2 330 |
Sample Input 2 | Sample Output 2 |
---|---|
7 1 30 270 995 996 997 998 999 |
2 570 |
Sample Input 3 | Sample Output 3 |
---|---|
7 2 30 270 995 996 997 998 999 |
0 0 |
Sample Input 4 | Sample Output 4 |
---|---|
3 0 1 300 299 |
2 301 |
Footnotes
- The largest number of problems in an official ACM ICPC to date is probably the recent ACM ICPC World Finals in Marrakesh, Morocco where N=13N=13.
- To simplify this problem a bit, we ignore seconds although the last submission must be done at 0404 hours, 5959minutes, and 5959 seconds (or minute 299299) in order to be considered valid.
题意
解释一下样例,输入n,p,n代表总题数,p代表第一个开始做第p题(位置从0开始),后面输入的是每一道题至少需要的时间,做了第一题后,选择最少需要的时间加上累积的时间<=300的话就是可做的,因为一道题的限制时间是300,问做出来的总题数和总时间。
思路
首先判断a[p]是否<=300,然后把a[0]与a[p]替换,将数组排序,先存下做出每一题的总时间,然后遍历判断
代码
#include<bits/stdc++.h> using namespace std; int main() { int n, p; while(cin >> n >> p) { int a[n]; int nn = 0, pp = 0, cnt = 0; for(int i = 0; i < n; i++) cin >> a[i]; if(a[p] <= 300) { int tmp = a[0]; a[0]=a[p]; a[p]=tmp; sort(a+1, a + n); for(int i=1;i<n;i++){ a[i]+=a[i-1]; } for(int i = 0; i < n; i++) { if(a[i] <= 300) { pp += a[i]; cnt++; } else if(a[i] > 300) break; } } cout << cnt << " " << pp << endl; } }
以上是关于Kattis - Association for Computing Machinery的主要内容,如果未能解决你的问题,请参考以下文章
Kattis-Association for Computing Machinery
Kattis-Association for Computing Machinery
Association for the Country of Mububa Kattis - mububa (DP)
J - Association of Cats and Magical Lights Kattis - magicallights (树状数组+dfs序)