Kattis-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 N 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! 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)] 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 300 minute contest.

The first line contains two non-negative integers 2≤N≤13 and 0≤p≤N−1. The integer N describes the number of problems in the problem set of this ACM ICPC and the integer p is a 0-based index that describes the problem id that your team wants to solve first before attempting the other N−1 problems.

The next line contains N integers in the range between 1 and 999, inclusive. Each integer i describes the estimated number of minutes to solve problem id i 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 5 hours, or 300 minutes, any estimation of strictly larger than 300 minutes for a certain problem j basically says that you estimate that your team cannot solve problem j 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 30 minutes to solve problem k, 270 minutes to solve another problem l, and have no idea how to solve the rest, and decides to solve problem k first followed by l, then   after   30 minutes have elapsed from the start of contest, your team really gets an ‘Accepted’ verdict from Kattis for problem k, immediately switches to   problem l for the next 270 minutes, gets another ‘Accepted’ verdict from Kattis for problem l at exactly 300 minutes (in this problem, submission at minute 300 is a valid submission2). Thus you have 2 Accepted problems and the total penalty time of 30+300=330 minutes as per the ICPC rules.

Output

Print two integers Num_AC and Penalty_Time separated by a single space in one line.

Num_AC is the highest number of problems that your team can solve  and     Penalty_Time is the lowest penalty minutes that your team can get in order to solve Num_AC problems in this 300 minutes ACM ICPC if your team insists to solve problem p first from the start of the contest and then use the remaining time to work on the other N−1 problems.

For the example scenario above, if your team decides to solve problem l first followed by k, then your team still solves Num_AC=2 Accepted problems, but with the total penalty of 270 + 300= 570 minutes.

Footnotes

  1. 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=13.

  2. To simplify this problem a bit, we ignore seconds although the last submission must be done at 04 hours, 59 minutes, and 59 seconds (or minute 299) in order to be considered valid.

代码

#include<iostream>
#include<algorithm>
using namespace std;

int main() {
	int n, p,a[13];
	int c = 0;
	int d = 0;
	cin >> n >> p;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (a[p] <=300) {
		swap(a[0], a[p]);
		sort(a + 1, a + n);
		for (int i = 1; i < n; i++) {
			a[i] = a[i] + a[i - 1];
		}
		for (int i = 0; i < n; i++) {
			if (a[i] <= 300) {
				d = d + a[i];
				c++;
			}
			else {
				break;
			}
		}
	}
	cout << c << " " << d;
}

结束语

好兄弟好兄弟,留下你的关注和点赞,666走一波!!!!!

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

做一个AC梦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值