A. Elections

链接

[http://codeforces.com/contest/1043/problem/A]

题意

有n个投票人已经投个对手ai票,让你求最小的k使得k-ai加起来大于,对手得票总和

分析

一个个往后枚举即可

代码

#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,i;
	int a[101];
	while(cin>>n){
		int k=0;
		int sum=0;
		for(i=0;i<n;i++){
			cin>>a[i];
			sum+=a[i];
			k=max(k,a[i]);
		}
		while(true){
			if(n*k-sum>sum) break;
			else k++;
		}
		cout<<k<<endl;
	}
	return 0;
}
posted @ 2018-10-29 21:29  ChunhaoMo  阅读(156)  评论(0)    收藏  举报