gym 102220J Time Limit

In CCPC contests, you will get “Time Limit Exceeded” when your program tried to run during too much time. Setting suitable time limit for problems is vital to a contest.

Mr. Bread is preparing problems for a coming contest with his friends. For each problem, there will be a “Main Correct Solution” denotes the standard solution program written by the author. There will also be several “Correct Solutions” denote solution programs intended to pass.

Assume there are n programs in total, labeled by 1,2,…,n. The 1-th program denotes the “Main Correct Solution” while others are “Correct Solutions”. The i-th program runs in ai seconds.

According to the rules in Mr. Bread’s mind, the time limit x should meet all the rules below:

The constraint can’t be too tight, which means x≥3a1.
All the “Correct Solutions” should pass, which means x≥ai+1 for all i∈[2,n].
x should be the smallest even integer meeting the rules described above.
Please write a program to find the time limit x.

Input
The first line of the input contains an integer T(1≤T≤10), denoting the number of test cases.

In each test case, there is one integer n(2≤n≤10) in the first line, denoting the number of programs.

In the second line, there are n integers a1,a2,…,an(1≤ai≤10).

Output
For each test case, print a single line containing an integer, denoting the value of x.

Example
Input
2
2
1 3
2
1 4
Output
4
6
为什么我这么水的题目都要水一篇博客呢?
啥也别说了,even nuber是偶数的意思

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int t, n, i;
	int a[11];
	int maxx;
	scanf("%d\n", &t);
	while (t--)
	{
		maxx = -1;
		scanf("%d", &n);
		scanf("%d", &a[1]);
		a[1] = 3 * a[1];
		for (i = 2; i <= n; i++) {
			scanf("%d", &a[i]);
			a[i] += 1;
		}
		for (i = 1; i <= n; i++) {
			maxx = maxx > a[i] ? maxx : a[i];
		}
		if (maxx % 2 != 0)
			maxx++;
		printf("%d\n", maxx);
	}
	return 0;
}

还有,代码错误的原因多种多样,比如报time limit不一定是代码错了,还有可能是语言交错了,(不过你在比赛时真的敢冒着加罚时的风险交一份与上次一模一样的代码吗)
(全是c++)

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值