题意:给定n个数字,第i个为a[i],求使得sigma k-a[i]>sigma a[i]最小的k
n,a[i]<=1e2
思路:
1 #include<cstdio> 2 #include<cstring> 3 #include<string> 4 #include<cmath> 5 #include<iostream> 6 #include<algorithm> 7 #include<map> 8 #include<queue> 9 #include<vector> 10 #include<ctime> 11 using namespace std; 12 typedef long long ll; 13 typedef unsigned int uint; 14 typedef unsigned long long ull; 15 typedef pair<int,int> PII; 16 typedef vector<int> VI; 17 #define fi first 18 #define se second 19 #define MP make_pair 20 #define N 210000 21 #define M 130 22 #define MOD 1000000007 23 #define eps 1e-8 24 #define pi acos(-1) 25 26 int main() 27 { 28 int n; 29 scanf("%d",&n); 30 int s=0; 31 int mx=0; 32 for(int i=1;i<=n;i++) 33 { 34 int x; 35 scanf("%d",&x); 36 s+=x; 37 mx=max(mx,x); 38 } 39 int ans=2*s/n; 40 if(ans*n<=2*s) ans++; 41 ans=max(ans,mx); 42 printf("%d ",ans); 43 return 0; 44 }