/* * Author: ***** * Created Time: 2013/9/29 23:08:06 * File Name: C.cpp * solve: C.cpp */ #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> #include<string> #include<map> #include<stack> #include<set> #include<iostream> #include<vector> #include<queue> //ios_base::sync_with_stdio(false); //#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; #define sz(v) ((int)(v).size()) #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define repf(i, a, b) for (int i = (a); i <= (b); ++i) #define repd(i, a, b) for (int i = (a); i >= (b); --i) #define clr(x) memset(x,0,sizeof(x)) #define clrs( x , y ) memset(x,y,sizeof(x)) #define out(x) printf(#x" %d\n", x) #define sqr(x) ((x) * (x)) typedef long long LL; const int INF = 1000000000; const double eps = 1e-8; const int maxn = 100010; int sgn(const double &x) { return (x > eps) - (x < -eps); } LL num[maxn]; int n; LL maxround; bool ok(LL round) { LL cnt = 0; rep(i,0,n) { cnt += (round - num[i]); } return cnt >= round && cnt >= maxround; } int main() { //freopen("in.txt","r",stdin); scanf("%d",&n); maxround = 0; LL sum = 0; rep(i,0,n) { scanf("%I64d",&num[i]); maxround = max(maxround,num[i]); sum += num[i]; } LL L = maxround; LL R = sum; LL mid; while(L <= R) { //cout<<"yes"<<endl; mid = (L + R)/2; if(ok(mid)) R = mid - 1; else L = mid + 1; } cout<<L<<endl; return 0; }
/* * Author: ***** * Created Time: 2013/9/29 23:08:06 * File Name: C.cpp * solve: C.cpp */ #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> #include<string> #include<map> #include<stack> #include<set> #include<iostream> #include<vector> #include<queue> //ios_base::sync_with_stdio(false); //#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; #define sz(v) ((int)(v).size()) #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define repf(i, a, b) for (int i = (a); i <= (b); ++i) #define repd(i, a, b) for (int i = (a); i >= (b); --i) #define clr(x) memset(x,0,sizeof(x)) #define clrs( x , y ) memset(x,y,sizeof(x)) #define out(x) printf(#x" %d\n", x) #define sqr(x) ((x) * (x)) typedef long long LL; const int INF = 1000000000; const double eps = 1e-8; const int maxn = 100010; int sgn(const double &x) { return (x > eps) - (x < -eps); } LL num[maxn]; int n; LL maxround; bool ok(LL round) { LL cnt = 0; rep(i,0,n) { cnt += (round - num[i]); } return cnt >= round; } int main() { //freopen("in.txt","r",stdin); scanf("%d",&n); maxround = 0; LL sum = 0; rep(i,0,n) { scanf("%I64d",&num[i]); maxround = max(maxround,num[i]); sum += num[i]; } LL L = maxround; LL R = sum; LL mid; while(L <= R) { //cout<<"yes"<<endl; mid = (L + R)/2; if(ok(mid)) R = mid - 1; else L = mid + 1; } cout<<L<<endl; return 0; }