A. Elections

链接

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

题意

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

分析

一个个往后枚举即可

代码

#include
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>a[i];
            sum+=a[i];
            k=max(k,a[i]);
        }
        while(true){
            if(n*k-sum>sum) break;
            else k++;
        }
        cout<

转载于:https://www.cnblogs.com/mch5201314/p/9873415.html

你可能感兴趣的:(A. Elections)