CF1043A.Elections

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are nn students in the school. Each student has exactly kk votes and is obligated to use all of them. So Awruk knows that if a person gives aia_i votes for Elodreip, than he will get exactly k−aik - a_i votes from this person. Of course 0≤k−ai0 \le k - a_i holds.

Awruk knows that if he loses his life is over. He has been speaking a lot with his friends and now he knows a1,a2,…,ana_1, a_2, \dots, a_n — how many votes for Elodreip each student wants to give. Now he wants to change the number kk to win the elections. Of course he knows that bigger kk means bigger chance that somebody may notice that he has changed something and then he will be disqualified.

So, Awruk knows a1,a2,…,ana_1, a_2, \dots, a_n — how many votes each student will give to his opponent. Help him select the smallest winning number kk. In order to win, Awruk needs to get strictly more votes than Elodreip.

阿武鲁克正在参加学校的选举。现在是最后一轮。他只有一个对手——埃洛德雷普。学校共有 nn 名学生,每名学生恰好有 kk 票,并且必须全部投出。因此阿武鲁克知道:若某位学生给埃洛德雷普投了 aia_i 票,则此人将给他本人投恰好 k−aik - a_i 票。显然,必须满足 0≤k−ai0 \le k - a_i。

阿武鲁克深知:一旦落败,他的生命就将终结。他已与朋友们进行了大量沟通,从而得知 a1,a2,…,ana_1, a_2, \dots, a_n —— 即每位学生打算投给对手的票数。现在,他希望调整 kk 的值以赢得选举。当然,他清楚:kk 越大,越可能被人察觉其篡改行为,从而导致自己被取消资格。

因此,阿武鲁克已知 a1,a2,…,ana_1, a_2, \dots, a_n —— 即每位学生将投给对手的票数。请帮他选出最小的、能确保获胜的 kk 值。为赢得选举,阿武鲁克获得的总票数必须严格大于埃洛德雷普的总票数。

输入格式

The first line contains integer nn (1≤n≤1001 \le n \le 100) — the number of students in the school.

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1001 \leq a_i \leq 100) — the number of votes each student gives to Elodreip.

第一行包含一个整数 nn(1≤n≤1001 \le n \le 100)—— 表示学校中学生的数量。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1001 \leq a_i \leq 100)—— 表示每位学生投给 Elodreip 的票数。

输出格式

Output the smallest integer kk (k≥max⁡aik \ge \max a_i) which gives Awruk the victory. In order to win, Awruk needs to get strictly more votes than Elodreip.

输出满足条件的最小整数 kk(k≥max⁡aik \ge \max a_i),使得 Awruk 获胜。为赢得胜利,Awruk 的票数必须严格多于 Elodreip 的票数。

输入输出样例

  • 输入#1

    5
    1 1 1 5 1

    输出#1

    5
  • 输入#2

    5
    2 2 3 2 2

    输出#2

    5

说明/提示

In the first example, Elodreip gets 1+1+1+5+1=91 + 1 + 1 + 5 + 1 = 9 votes. The smallest possible kk is 55 (it surely can't be less due to the fourth person), and it leads to 4+4+4+0+4=164 + 4 + 4 + 0 + 4 = 16 votes for Awruk, which is enough to win.

In the second example, Elodreip gets 1111 votes. If k=4k = 4, Awruk gets 99 votes and loses to Elodreip.

在第一个例子中,Elodreip 获得了 1+1+1+5+1=91 + 1 + 1 + 5 + 1 = 9 票。最小可能的 kk 是 55(由于第四个人的存在,kk 显然不能更小),此时 Awruk 获得 4+4+4+0+4=164 + 4 + 4 + 0 + 4 = 16 票,足以获胜。

在第二个例子中,Elodreip 获得了 1111 票。若 k=4k = 4,Awruk 获得 99 票,输给 Elodreip。

输入解题思路,AI测评打分。不知道怎么写?

首页