text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 10; int a[MAX_N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); long long cnt = 0; for (int i = n - 2; i >= 0; i--) { cnt += a[n - 1] - a[i]; } for (int i = a[n - 1];; i++) { if (i != a[n - 1]) { cnt += n; } if (cnt >= i) { cout << i; return 0; } } }
#include <bits/stdc++.h> using namespace std; int main() { long long n, n2; cin >> n; n2 = n; long long x = 0; long long Max = 0; while (n2--) { long long a; cin >> a; x += a; Max = max(Max, a); } long long ans = 0; for (long long i = Max;; i++) { if ((n - 1) * i >= x) { ans = i; break; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; long long offset = 1000000000; const long long N = 1e5; long long power(long long x, long long y) { long long res = 1; while (y) { if (y & 1) res = res * x; y = y >> 1; x = x * x; } res = res * x; return res; } vector<vector<long long> > divi(long long n) { vector<vector<long long> > v(n + 1); for (long long i = 1; i < n + 1; i++) { for (long long j = 1; j * j <= i; j++) { if (i % j == 0) { if (j * j == i) { v[i].push_back(j); } else { v[i].push_back(j), v[i].push_back(i / j); } } } } return v; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long tcount; tcount = 1; while (tcount--) { long long n; cin >> n; vector<long long> a(n); for (long long i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); reverse(a.begin(), a.end()); long long mx = a[0]; long long ind = 0; for (long long i = 1; i < n - 1; i++) { if (a[i] == a[i - 1]) ind = i; else break; } long long cmx = mx; long long f = 0; for (long long i = 1; i < n; i++) { long long dif = mx - a[i]; if (dif <= cmx) cmx -= dif; else { cmx = 0; break; } } long long ans = cmx / (n - 1) + ((cmx % (n - 1)) != 0); cout << ans + mx << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int n; long long a[100005]; bool C(long long x) { long long sum = 0; for (int i = 0; i < n; i++) { if (x < a[i]) return false; sum += (x - a[i]); } if (sum >= x) return true; return false; } int main() { cin >> n; long long Max = -1; for (int i = 0; i < n; i++) { cin >> a[i]; Max = max(Max, a[i]); } long long r = Max * 10; long long l = 0; while (l < r) { long long mid = (l + r) / 2; if (C(mid)) { r = mid; } else { l = mid + 1; } } cout << l << endl; }
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; long long sum = 0, mx = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { long long t; cin >> t; sum += t; mx = max(mx, t); } cout << max(mx, sum / (n - 1) + (sum % (n - 1) != 0)) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, x, y = 0, mx = -2, t; cin >> n; for (i = 0; i < n; i++) { cin >> x; y += x; mx = max(x, mx); } n--; t = y / n + (y % n != 0); t = max(t, mx); cout << t << endl; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int n, a[MAXN]; bool ok(long long X) { long long s = 0; bool ok = 0; for (int i = 1; i <= n; i++) { if (X < a[i]) return 0; s += X - a[i]; if (!ok && s >= X) ok = 1; } return ok; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); long long lo = 1, hi = 1e15, F = 1e15; while (lo <= hi) { long long md = (lo + hi) / 2; if (ok(md)) { hi = md - 1; F = min(F, md); } else lo = md + 1; } printf("%lld", F); }
#include <bits/stdc++.h> using namespace std; long long n; long long sum, mx, val; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> val; mx = max(mx, val); sum += val; } n--; cout << max(mx, sum / (long long)n + (sum % n != 0)); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int k, i, sum = 0, maxx = -1, n; cin >> n; for (i = 1; i <= n; i++) { cin >> k; sum += k; maxx = max(maxx, k); } cout << max(maxx, (sum - 1) / (n - 1) + 1) << endl; }
#include <bits/stdc++.h> using namespace std; using namespace std; long long int n, a[((int)1e5 + 5)]; int f(long long int t) { long long int k = 0; for (long long int i = 1; i <= n; i++) if (a[i] > t) return 0; else k += t - a[i]; return k >= t; } int main() { cin >> n; for (long long int i = 1; i <= n; i++) scanf("%d", a + i); long long int b = 1; long long int e = 2e9; while (b < e) { if (f((b + e) / 2)) e = (b + e) / 2; else b = (b + e) / 2 + 1; } cout << b << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; const int Nmax = 100010; long long N, A[Nmax]; bool cmp(int a, int b) { return a > b; } bool good(long long x) { long long tot = 0; for (int i = 1; i <= N; ++i) tot += x - A[i]; if (tot >= x) return 1; return 0; } long long BS(long long st, long long dr) { if (st == dr) return st; long long mid = (st + dr) / 2; if (good(mid)) return BS(st, mid); return BS(mid + 1, dr); } int main() { cin >> N; for (int i = 1; i <= N; ++i) cin >> A[i]; sort(A + 1, A + N + 1, cmp); cout << BS(A[1], 1LL << 40) << '\n'; }
#include <bits/stdc++.h> using namespace std; long long int n, x, sum = 0, z = LONG_MIN, k; int main() { cin >> n; k = n; while (n--) cin >> x, sum += x, (x > z) ? z = x : x = 0; return (z >= ((sum + (k - 2)) / (k - 1))) ? cout << z : cout << (sum + (k - 2)) / (k - 1), 0; }
#include <bits/stdc++.h> using namespace std; long long a[100005]; long long ans, first, last, minimal, cnt, n, ost; int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); } int main() { ans = 0; scanf("%I64d", &n); for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]); qsort(a, n + 1, sizeof(long long), compare); for (int i = 2; i < n; i++) { if (a[n] - a[i] < a[1]) { ans += (a[n] - a[i]); a[1] -= (a[n] - a[i]); } else { ans += a[1]; a[1] = 0; } if (a[1] == 0) break; } if (a[1] == 0) { ans += (a[n] - ans); } else { a[n] -= ans; a[n] -= (a[1] / (n - 1)) * (n - 2); ost = a[1] % (n - 1); a[n] -= ost; if (ost > 0) a[n]++; ans += a[n] + a[1]; } printf("%I64d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; bool predicate(long long int rounds, vector<long long int> &v, long long int sum) { long long int n = v.size(); long long int a = (n - 1) * rounds; long long int b = sum; long long int c = v[0]; if ((a - b) >= c) return true; else return false; } long long int binsearch(long long int lo, long long int hi, long long int n, vector<long long int> &v, long long int sum) { while (lo < hi) { long long int mid = lo + (hi - lo) / 2; if (predicate(mid, v, sum)) { hi = mid; } else { lo = mid + 1; } } return lo; } void Compute(long long int n) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); vector<long long int> v(n); long long int sum = 0; for (long long int i = 0; i < n; i++) { cin >> v[i]; } sort(v.begin(), v.end()); for (long long int i = 1; i < n; i++) { sum += v[i]; } long long int maxim = v[n - 1]; long long int rounds = binsearch(maxim, 1e14, n, v, sum); cout << rounds << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n; cin >> n; Compute(n); }
#include <bits/stdc++.h> using namespace std; int main() { int n; long long x, sum = 0, max1 = -1, fsum = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> x; sum += x; max1 = max(max1, x); } if (sum % (n - 1)) fsum = 1; fsum += sum / (n - 1); long long re = max(max1, fsum); cout << re << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; long long n, A[N], sum; int main() { scanf("%I64d", &n); for (int i = 0; i < n; i++) scanf("%I64d", A + i); sort(A, A + n); long long lo = A[n - 1], hi = 2e9, mid, ans; while (lo < hi) { mid = (hi + lo) / 2; sum = 0; for (int i = 0; i < n; i++) sum += mid - A[i]; if (sum >= mid) hi = mid, ans = mid; else lo = mid + 1; } printf("%I64d\n", ans); }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long a[n]; long long s = 0; long long an = -1; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; an = max(an, a[i]); } long long p = s / (n - 1); long long ans; if (s % (n - 1) == 0) { ans = p; } else ans = p + 1; cout << max(ans, an) << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a[100005], maximum = 0, low, high, mid, total = 0, i; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; total += a[i]; maximum = max(maximum, a[i]); } low = maximum; high = 2 * maximum; while (low < high) { mid = (low + high) / 2; if (mid * (n - 1) >= total) high = mid; else low = mid + 1; } cout << low << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); long long t, i; cin >> t; long long A[t], m = -1, s = 0, a; for (i = 0; i < t; i++) { cin >> A[i]; s += A[i]; m = m < A[i] ? A[i] : m; } a = (s % (t - 1)) ? (s / (t - 1) + 1) : (s / (t - 1)); if (m > a) cout << m; else cout << a; return 0; }
#include <bits/stdc++.h> using namespace std; #pragma pack(4) const double pi = acos(-1.0); const int inf = 0x7f7f7f7f; const long long INF = 0x7f7f7f7f7f7f7f7fll; const int go[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; inline bool RD(int& a) { return scanf("%d", &a) != EOF; } inline bool RD(char& a) { return scanf("%c", &a) != EOF; } inline bool RD(char* a) { return scanf("%s", a) != EOF; } inline bool RD(double& a) { return scanf("%lf", &a) != EOF; } inline bool RD(long long& a) { return scanf("%I64d", &a) != EOF; } template <class T1> inline bool IN(T1& a) { return RD(a); } template <class T1, class T2> inline bool IN(T1& a, T2& b) { return RD(a) && RD(b); } template <class T1, class T2, class T3> inline bool IN(T1& a, T2& b, T3& c) { return RD(a) && RD(b) && RD(c); } template <class T1, class T2, class T3, class T4> inline bool IN(T1& a, T2& b, T3& c, T4& d) { return RD(a) && RD(b) && RD(c) && RD(d); } template <class T1, class T2, class T3, class T4, class T5> inline bool IN(T1& a, T2& b, T3& c, T4& d, T5& e) { return RD(a) && RD(b) && RD(c) && RD(d) && RD(e); } template <class T1, class T2, class T3, class T4, class T5, class T6> inline bool IN(T1& a, T2& b, T3& c, T4& d, T5& e, T6& f) { return RD(a) && RD(b) && RD(c) && RD(d) && RD(e) && RD(f); } template <class T1, class T2, class T3, class T4, class T5, class T6, class T7> inline bool IN(T1& a, T2& b, T3& c, T4& d, T5& e, T6& f, T7& g) { return RD(a) && RD(b) && RD(c) && RD(d) && RD(e) && RD(f) && RD(g); } inline void PT(int a) { printf("%d", a); } inline void PT(char a) { printf("%c", a); } inline void PT(char* a) { printf("%s", a); } inline void PT(double a) { printf("%f", a); } inline void PT(long long a) { printf("%I64d", a); } inline void PT(const char a[]) { printf("%s", a); } template <class T1> inline void OT(T1 a) { PT(a); } template <class T1, class T2> inline void OT(T1 a, T2 b) { PT(a), PT(' '), PT(b); } template <class T1, class T2, class T3> inline void OT(T1 a, T2 b, T3 c) { PT(a), PT(' '), PT(b), PT(' '), PT(c); } template <class T1, class T2, class T3, class T4> inline void OT(T1 a, T2 b, T3 c, T4 d) { PT(a), PT(' '), PT(b), PT(' '), PT(c), PT(' '), PT(d); } template <class T1, class T2, class T3, class T4, class T5> inline void OT(T1 a, T2 b, T3 c, T4 d, T5 e) { PT(a), PT(' '), PT(b), PT(' '), PT(c), PT(' '), PT(d), PT(' '), PT(e); } template <class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(T1 a, T2 b, T3 c, T4 d, T5 e, T6 f) { PT(a), PT(' '), PT(b), PT(' '), PT(c), PT(' '), PT(d), PT(' '), PT(e), PT(' '), PT(f); } template <class T1, class T2, class T3, class T4, class T5, class T6, class T7> inline void OT(T1 a, T2 b, T3 c, T4 d, T5 e, T6 f, T7 g) { PT(a), PT(' '), PT(b), PT(' '), PT(c), PT(' '), PT(d), PT(' '), PT(e), PT(' '), PT(f), PT(' '), PT(g); } template <class T1> inline void OL(T1 a) { PT(a), PT('\n'); } template <class T1, class T2> inline void OL(T1 a, T2 b) { PT(a), PT(' '), PT(b), PT('\n'); } template <class T1, class T2, class T3> inline void OL(T1 a, T2 b, T3 c) { PT(a), PT(' '), PT(b), PT(' '), PT(c), PT('\n'); } template <class T1, class T2, class T3, class T4> inline void OL(T1 a, T2 b, T3 c, T4 d) { PT(a), PT(' '), PT(b), PT(' '), PT(c), PT(' '), PT(d), PT('\n'); } template <class T1, class T2, class T3, class T4, class T5> inline void OL(T1 a, T2 b, T3 c, T4 d, T5 e) { PT(a), PT(' '), PT(b), PT(' '), PT(c), PT(' '), PT(d), PT(' '), PT(e), PT('\n'); } template <class T1, class T2, class T3, class T4, class T5, class T6> inline void OL(T1 a, T2 b, T3 c, T4 d, T5 e, T6 f) { PT(a), PT(' '), PT(b), PT(' '), PT(c), PT(' '), PT(d), PT(' '), PT(e), PT(' '), PT(f), PT('\n'); } template <class T1, class T2, class T3, class T4, class T5, class T6, class T7> inline void OL(T1 a, T2 b, T3 c, T4 d, T5 e, T6 f, T7 g) { PT(a), PT(' '), PT(b), PT(' '), PT(c), PT(' '), PT(d), PT(' '), PT(e), PT(' '), PT(f), PT(' '), PT(g), PT('\n'); } template <class T> inline T lb(T i) { return i & -i; } template <class T> inline T lc(T i) { return i << 1; } template <class T> inline T rc(T i) { return i << 1 | 1; } template <class T> inline T at(T a, int i) { return a & (T(1) << i); } template <class T> inline T nt(T a, int i) { return a ^ (T(1) << i); } template <class T> inline T s1(T a, int i) { return a | (T(1) << i); } template <class T> inline T s0(T a, int i) { return a & ~(T(1) << i); } const double eps = 1e-8; inline int cmp(double a, double b = 0) { return fabs(a - b) < eps ? 0 : ((a - b) > eps ? +1 : -1); } inline double fmax(double a, double b) { return cmp(a, b) > 0 ? a : b; } inline double fmin(double a, double b) { return cmp(a, b) < 0 ? a : b; } long long n, a; int main() { while (IN(n)) { long long sum = 0, up = 0; for (int i = int(0), _i = int(n - 1); i <= _i; i++) { IN(a); sum += a; if (a > up) up = a; } long long ans = (sum + n - 2) / (n - 1); if (ans < up) OL(up); else OL(ans); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int a[n]; long long int sum = 0; long long int mx = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; mx = max(mx, a[i]); } sum = ceil((double)((double)sum / (double)(n - 1))); cout << max(mx, sum); }
#include <bits/stdc++.h> using namespace std; void init() {} long long n, sum = 0, maxele = 0; long long binarySearch(long long low, long long high) { long long result = high; while (low <= high) { long long mid = low + (high - low) / 2; if (mid * (n - 1) >= sum) { result = mid; high = mid - 1; } else { low = mid + 1; } } return result; } int main() { init(); ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { long long temp; cin >> temp; sum += temp; maxele = max(maxele, temp); } long long m = binarySearch(1, sum); if (m > maxele) cout << m; else cout << maxele; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, sum = 0, inp, mx = 0; scanf("%lld", &n); for (int y = 0; y < (int)n; y++) { scanf("%lld", &inp); sum += inp; mx = max(mx, inp); } long long res = (sum % (n - 1)) != 0; printf("%lld", max(mx, sum / (n - 1) + res)); }
#include <bits/stdc++.h> using namespace std; long long ceil(long long a, long long b) { return (a + b - 1) / b; } int main() { ios_base::sync_with_stdio(false); int n; cin >> n; int i, j; long long sum = 0LL, temp, mx = 0; for (i = 0; i < n; i++) { cin >> temp; sum += temp; mx = max(mx, temp); } cout << max(ceil(sum, (long long)n - 1), mx) << '\n'; }
#include <bits/stdc++.h> using namespace std; long long arr[1000010]; int N; bool check(long long K) { long long superCount = K; for (int i = 0; i < N; i++) { superCount -= (K - arr[i]); } return superCount <= 0; } int main() { cin >> N; long long high = 0; for (int i = 0; i < N; i++) { cin >> arr[i]; high += arr[i]; } sort(arr, arr + N); long long low = arr[N - 1]; while (low != high) { long long mid = (low + high) / 2; if (check(mid)) high = mid; else low = mid + 1; } cout << low << endl; }
#include <bits/stdc++.h> using namespace std; int max1(int a, int b) { return a > b ? a : b; } int main() { long long int n, i, a[100010], max2, x = 0, s = 0; scanf("%I64d", &n); for (i = 0; i < n; i++) { scanf("%I64d", &a[i]); s += a[i]; } sort(a, a + n); if (s % (n - 1)) x = (s / (n - 1)) + 1; else x = s / (n - 1); if (x < a[n - 1]) x = a[n - 1]; printf("%I64d\n", x); return 0; }
#include <bits/stdc++.h> using namespace std; int n, a; long long sum, x; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a); x = max(x, a + 0ll); sum += a; } printf("%I64d", max(x, (sum + n - 2) / (n - 1))); }
#include <bits/stdc++.h> using namespace std; int main() { int n, i; long long a, ans, sum = 0, mx = -1; cin >> n; for (i = 0; i < n; i++) { cin >> a; sum += a; mx = ((mx >= a) ? (mx) : (a)); } if ((sum % (n - 1)) == 0) ans = sum / (n - 1); else ans = (sum / (n - 1) + 1); if (ans < mx) ans = mx; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long int key[100080]; inline long long int max(long long int a, long long int b) { return a > b ? a : b; } int main() { long long int n; while (scanf("%I64d", &n) != EOF) { long long int sum = 0, ans1 = 0; for (int i = 1; i <= n; i++) { scanf("%I64d", &key[i]); sum += key[i]; ans1 = max(ans1, key[i]); } long long int ans = sum / (n - 1); if (ans * (n - 1) < sum) ans++; ans = max(ans, ans1); printf("%I64d\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; long long int n, x, sum = 0, z = LONG_MIN; int main() { ios_base::sync_with_stdio(0); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> n; for (int i = 1; i <= n; ++i) cin >> x, sum += x, (x > z) ? z = x : x = 0; if (z >= ((sum + (n - 2)) / (n - 1))) cout << z << "\n"; else cout << (sum + (n - 2)) / (n - 1) << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, max = 0, r; double p = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> k; p += k; if (k > max) max = k; } p = (p - 1) / (n - 1) + 1; r = p; if (max > r) cout << max << endl; else cout << r << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long int M = 1000000007; long long int i, j; bool sortbysecdesc(const pair<int, int> &a, const pair<int, int> &b) { return a.second > b.second; } long long int mod(long long a, long long b) { return (a % b + b) % b; } long long int isPrime(long long int n) { if (n <= 3) return (1); if (n % 2 == 0 || n % 3 == 0) return (0); for (i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return (0); return (1); } long long int smallestDivisor(long long int n) { if (n % 2 == 0) return 2; for (i = 3; i * i <= n; i += 2) { if (n % i == 0) return i; } return n; } long long int countDivisors(long long int n) { long long int cnt = 0; for (i = 1; i <= sqrt(n); i++) { if (n % i == 0) { if (n / i == i) cnt++; else cnt = cnt + 2; } } return cnt; } long long maxPrimeFactors(long long n) { long long maxPrime = -1; while (n % 2 == 0) { maxPrime = 2; n >>= 1; } for (i = 3; i <= sqrt(n); i += 2) { while (n % i == 0) { maxPrime = i; n = n / i; } } if (n > 2) maxPrime = n; return maxPrime; } int main() { ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL); long long int tt = 1; while (tt--) { long long int n; cin >> n; long long int a[n], sum = 0; for (i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } long long int num = *max_element(a, a + n); long long int x = ceil((double)sum / (n - 1)); cout << max(num, x) << "\n"; } }
#include <bits/stdc++.h> using namespace std; long long int n; long long int bin(long long int x, long long int beg, long long int last) { long long int mid = (beg) + ((last - beg) / 2); if ((mid > 0) && (((mid) * (n - 1) > x) && ((mid - 1) * (n - 1) < x) || (mid * (n - 1) == x))) return mid; if (mid * (n - 1) < x) return bin(x, mid + 1, last); else return bin(x, beg, mid - 1); } int main() { cin >> n; long long int a[n]; long long int ma = 0, sum = 0; for (long long int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > ma) ma = a[i]; sum = sum + a[i]; } vector<long long int> b; long long int st = ma; long long int ans = 0; if ((n - 1) * ma >= sum) ans = ma; else { ans = bin(sum, ma, sum); } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a, ma = 0, cnt = 0; scanf("%I64d", &n); for (int i = 0; i < n; i++) { scanf("%I64d", &a); if (a > ma) ma = a; cnt += a; } a = ceil((double)cnt / (n - 1)), a = max(a, ma); printf("%I64d", a); return 0; }
#include <bits/stdc++.h> using namespace std; long long ans, i, n, k, g, b, p, us[400000], m = 1000000010, p1, m1, v, a[400000]; int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; p = max(p, a[i]); ans += a[i]; } k = ans / (n - 1); if (ans % (n - 1) != 0) k++; cout << max(k, p); return 0; }
#include <bits/stdc++.h> using namespace std; long long mode = pow(10, 9) + 7; bool cmp(pair<long double, int> x, pair<long double, int> y) { return x.first < y.first; } const long long maxn = 2 * 1e5 + 5; int main() { ios::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; long long a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); reverse(a, a + n); long long l = a[0], r = 1e12; long long ans = LLONG_MAX; while (l <= r) { long long m = (l + r) / 2; long long got = 0; for (int i = 0; i < n; i++) { got += (m - a[i]); } if (got >= m) { ans = m; r = m - 1; } else { l = m + 1; } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> long long int inp[100006]; int main() { int n; long long int tmp, sum = 0, max = INT_MIN; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%I64d", &tmp); if (max < tmp) max = tmp; sum += tmp; } long long int res = sum / (n - 1); if (sum % (n - 1) == 0 && res >= max) printf("%I64d", res); else if (res >= max) printf("%I64d", res + 1); else printf("%I64d", max); }
#include <bits/stdc++.h> using namespace std; const long long maxn = 5e5; long long n, a[maxn], sum = 0, ans = 0; int f(long long m) { if (n * m - sum >= m) return 1; return 0; } int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; sum += a[i]; } long long l = *max_element(a + 1, a + n + 1), r = 2e9; while (r - l > 1) { long long mid = (r + l) / 2; if (f(mid)) { r = mid; } else { l = mid; } } if (f(l)) { cout << l; } else { cout << r; } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long int n, x = 0, total = 0; cin >> n; vector<long long int> vi; for (int i = 1; i <= n; i++) { long long int a; cin >> a; total += a; vi.push_back(a); x = max(x, a); } n--; long long int ans = ceil((total * 1.0) / (n * 1.0)); if (ans >= x) cout << ans << "\n"; else cout << x << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; long long n, ans, sum, maxx; long long a[maxn]; bool check(long long round) { if (n * round - sum >= round) return 1; return 0; } int main() { scanf("%lld", &n); for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]), sum += a[i], maxx = max(maxx, a[i]); long long l = maxx, r = 100000000000000LL; while (l <= r) { long long mid = (l + r) / 2; if (check(mid)) ans = mid, r = mid - 1; else l = mid + 1; } printf("%lld\n", ans); }
#include <bits/stdc++.h> using namespace std; const int NMAX = 100000; const int INF = 0x3f3f3f3f; const int dx[] = {0, 0, -1, 1}; const int dy[] = {-1, 1, 0, 0}; long long n, a, s, amax, rs; int main() { cin >> n; for (int i = 0; i < (n); ++i) { cin >> a; amax = (((a) > (amax)) ? (a) : (amax)); s += a; } rs = amax; a = amax * (1 - n) + s; if (a > 0) { rs += a / (n - 1); a = a % (n - 1); if (a % n != 0) rs++; } cout << rs; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, sum = 0, x, maxa = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> x; sum += x; maxa = max(maxa, x); } cout << max(maxa, (sum - 1) / (n - 1) + 1); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; long long a[n], i; long long sum = 0, maxi = 0; for (i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; maxi = max(maxi, a[i]); } long long ans = sum / (n - 1); if (sum % (n - 1) != 0) ans++; ans = max(ans, maxi); cout << ans << '\n'; }
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char *x) { cerr << '\"' << x << '\"'; } void __print(const string &x) { cerr << '\"' << x << '\"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template <typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template <typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); } void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); } void solve() { int n; cin >> n; vector<long long> a(n); long long sum = 0, m = -INT_MAX; for (auto &it : a) cin >> it, sum += it, m = max(m, it); cout << max(m, (sum + n - 2) / (n - 1)); } int main() { speed(); int T = 1; while (T--) { solve(); } }
#include <bits/stdc++.h> using namespace std; int n; int a[100005]; int main() { ios ::sync_with_stdio(false); while (cin >> n) { long long total = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; total += a[i]; } long long max = a[1]; for (int i = 1; i <= n; i++) if (a[i] > max) max = a[i]; long long ans = (total - 1) / (n - 1) + 1; if (ans < max) ans = max; cout << ans << endl; } return 0; }
#include <bits/stdc++.h> template <class T> inline T bigmod(T p, T e, T M) { long long int ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <class T> inline T modinverse(T a, T M) { return bigmod(a, M - 2, M); } template <typename T> T nCr(T n, T r) { if (r > n - r) r = n - r; int ans = 1, i; for (i = 1; i <= r; i++) { ans *= n - r + i; ans /= i; } return ans; } using namespace std; int main() { ios::sync_with_stdio(0); int n; cin >> n; vector<long long int> v(n); long long int sum = 0; long long int mx = 0; for (long long int& a : v) { cin >> a; sum += a; mx = max(mx, a); } while (true) { if (n * mx - sum >= mx) break; mx++; } cout << mx << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; long long s = 0; for (int i = 0; i < n; ++i) s += a[i]; long long l = 1, r = s; while (l < r) { long long m = l + (r - l) / 2; int count = 0; for (int i = 0; i < n; ++i) if (m >= a[i]) count++; long long diff = 0; if (count == n) { for (int i = 0; i < n; ++i) { diff += m - a[i]; } } if (diff >= m) r = m; else l = m + 1; } cout << l << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int a[100000]; int n; long long findNum(int level) { long long ans = 0; for (int i = 0; i < n; ++i) if (a[i] > level) return -1; else ans += level - a[i]; return ans; } int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) scanf("%d", &a[i]); int l = 0; int r = 2000000000; while (l + 1 < r) { int mid = ((long long)l + r) / 2; if (findNum(mid) < mid) l = mid; else r = mid; } printf("%d\n", r); return 0; }
#include <bits/stdc++.h> using namespace std; int n, a[100000]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", a + i); long long l = 1, r = 2e9, m, ans, sum, f; while (l <= r) { m = (l + r) / 2; sum = 0; f = 0; for (int i = 0; i < n; i++) if (m >= a[i]) sum += m - a[i]; else f = 1; if (sum >= m && !f) { r = m - 1; ans = m; } else { l = m + 1; } } printf("%I64d", ans); }
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; const int N = 1e6 + 7; int main() { long long n; cin >> n; long long a[n]; long long sum = 0; for (long long i = 0; i < (int)n; i++) { scanf("%lld", &a[i]); sum += a[i]; } sort(a, a + n); double e = (double)sum / (n - 1); long long ans = ceil(e); if (ans < a[n - 1]) cout << a[n - 1]; else cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; const long long int MOD = 1000000007; const long double PI = 3.14159265; long long int powerWithMod(long long int base, long long int exponent, long long int MODulus = LLONG_MAX) { long long int ansult = 1; base %= MODulus; while (exponent > 0) { if (exponent % 2 == 1) ansult = (ansult * base) % MODulus; exponent >>= 1; base = (base * base) % MODulus; } return ansult; } long long int gcdExtended(long long int a, long long int b, long long int *x, long long int *y) { cout << a << " " << b << " " << *x << " " << *y << "\n"; if (a == 0) { *x = 0, *y = 1; return b; } long long int x1, y1; long long int gcd = gcdExtended(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; cout << "AFTER " << a << " " << b << " " << *x << " " << *y << "\n"; return gcd; } long long int MODInverse(long long int a, long long int m) { long long int x, y; long long int g = gcdExtended(a, m, &x, &y); cout << g << " " << x << " " << y << "\n"; long long int ans = (x % m + m) % m; return ans; } using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long int n, a = 0, x, m = 0; cin >> n; for (int i = 1; i <= n; i++) cin >> x, a += x, m = max(x, m); cout << max(m, (a + n - 2) / (n - 1)) << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; const int pi = 3.1415; long long n, a[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long sum = 0, maxx = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; sum += a[i]; maxx = max(maxx, a[i]); } long long l = maxx, r = sum, ans; while (l <= r) { long long mid = (l + r) / 2; if (mid * (n - 1) >= sum) { ans = mid; r = mid - 1; } else l = mid + 1; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 100011; long long a[N]; int main() { ios ::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; long long left = *max_element(a, a + n); long long right = left * 2 + 1; long long sum = accumulate(a, a + n, 0LL); while (left + 1 < right) { long long mid = (left + right) / 2; if (n * (mid - 1) - sum >= mid - 1) right = mid; else left = mid; } cout << left << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int a[100010]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int del = 0, m = 1; long long res = 0; for (;;) { while (m < n && a[m] - del == a[0]) m++; if (m == n) { if (a[0] > 0) res += ((long long)a[0] * n - 1) / (n - 1) + 1; break; } else if (a[0] == 0) { res += a[n - 1] - del; break; } else if (a[0] >= m - 1) { int ret; if (m == 1) ret = a[m] - del - a[0]; else ret = min(a[0] / (m - 1), a[m] - del - a[0]); a[0] -= (long long)ret * (m - 1); del += (long long)ret * m; res += (long long)ret * m; } else { res += a[n - 1] - del; break; } } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m; long long movex[] = {0, 0, 1, -1}; long long movey[] = {1, -1, 0, 0}; signed main() { static const int _ = []() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); return 0; }(); long long t = 1; while (t--) { long long n, sum = 0, mx = 0; cin >> n; vector<long long> a(n); for (auto &i : a) { cin >> i; sum += i; mx = max(mx, i); } long long ans = 0; long long lo = mx, hi = sum; while (lo <= hi) { long long mid = lo + hi >> 1; if (mid * (n - 1) >= sum) { ans = mid; hi = mid - 1; } else { lo = mid + 1; } } cout << ans; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int player_num, i, j, game_number = -1, start, end; cin >> player_num; long long int plays_total = 0; for (i = 0; i < player_num; i++) { cin >> j; plays_total += j; game_number = max(game_number, j); } start = game_number; end = game_number * 2; while (start < end) { game_number = (start + end) / 2; if (game_number * player_num - plays_total >= game_number) end = game_number; else start = game_number + 1; } cout << start << endl; }
#include <bits/stdc++.h> using namespace std; int a[111111]; int main() { int i, n, max = 0; long long re; long long sum = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] > max) max = a[i]; sum += a[i]; } n--; re = sum / n; if (sum % n > 0) re++; if (max > re) re = max; cout << re << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long int n; long long int v[300005]; long long int check(long long int mid) { long long int ans = 0; for (int i = 0; i < n; ++i) { if (v[i] > mid) return -1; else ans += mid - v[i]; } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; cin >> n; for (int i = 0; i < n; ++i) { cin >> v[i]; } long long int s = 0; long long int e = INT_MAX; while (s + 1 < e) { long long int mid = s + e >> 1; if (check(mid) < mid) s = mid; else e = mid; } cout << e; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; long long sol = 0, aux, mx = -1; for (long long i = 0; i < N; i++) { cin >> aux; sol += aux; mx = max(mx, aux); } sol = max(mx, (sol % (N - 1) == 0 ? sol / (N - 1) : sol / (N - 1) + 1)); cout << sol << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x; while (scanf("%d", &n) == 1) { long long S = 0, maxi = 0; for (int i = 0; i < n; ++i) scanf("%d", &x), S += x, maxi = (maxi < x ? x : maxi); cout << max(maxi, (S - 1) / (n - 1) + 1) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long k, ans, sum(0), maxi(0); int t = n; while (t--) { long long x; cin >> x; maxi = max(maxi, x); sum += x; } k = (sum - 1) / (n - 1); ans = max(maxi, k + 1); cout << ans << endl; return 0; }
#include <bits/stdc++.h> const int N = 200005; const int mod = 1e9 + 7; const long long int inf = 999999999999999999; namespace modop { long long int madd(long long int a, long long int b) { return (a + b) % mod; } long long int msub(long long int a, long long int b) { return (((a - b) % mod) + mod) % mod; } long long int mmul(long long int a, long long int b) { return ((a % mod) * (b % mod)) % mod; } long long int mpow(long long int base, long long int exp) { long long int res = 1; while (exp) { if (exp % 2 == 1) { res = (res * base) % mod; } exp >>= 1; base = (base * base) % mod; } return res; } long long int minv(long long int base) { return mpow(base, mod - 2); } long long int mdiv(long long int a, long long int b) { return mmul(a, minv(b)); } } // namespace modop using namespace modop; using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; vector<long long int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); long long int sum = 0; for (int i = 0; i < n; i++) { sum += a[i]; } cout << max(a[n - 1], (sum + (n - 1) - 1) / (n - 1)); return 0; }
#include <bits/stdc++.h> using namespace std; long long a[200010]; int main() { int n; long long sum = 0, MAX = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%I64d", a + i); sum += a[i]; MAX = max(a[i], MAX); } long long ans; if (sum % (n - 1) == 0) ans = sum / (n - 1); else ans = sum / (n - 1) + 1; ans = max(MAX, ans); printf("%I64d\n", ans); }
#include <bits/stdc++.h> using namespace std; long long int p[200005], inv[200005], hell = pow(10, 9) + 7; long long int exp(long long int x, long long int y) { long long int res = 1; x %= hell; while (y) { if (y & 1) res = (res * x) % hell; y >>= 1; x = (x * x) % hell; } return res; } long long int bin(long long int n, long long int r) { if (n < r) return 0; long long int res = (p[n] * inv[n - r]) % hell; res = (res * inv[r]) % hell; return res; } int finde(char elem, int b, int e, string s) { for (int j = b; j < e; j++) { if ((int)s[j] == (int)elem) { return j; } } return -1; } long long binpow(long long a, long long b) { if (b == 0) return 1; long long res = binpow(a, b / 2); if (b % 2) return res * res * a; else return res * res; } bool sortpairs(const pair<int, int> &a, const pair<int, int> &b) { if (a.first == b.first) return a.second > b.second; return a.first < b.first; } bool isprime(long long int a) { for (int i = 2; i * i < a + 1; ++i) { if (a % i == 0) return false; } return true; } long long int snear(long long int arr[], long long int target, long long int end) { int start = 0; int ans = -1; while (start <= end) { int mid = (start + end) / 2; if (arr[mid] == target) { ans = mid; break; } if (arr[mid] > target) { end = mid - 1; } else { ans = mid; start = mid + 1; } } return ans; } void solve() { long long int a, b = 0, c = 0, t = 0, k = -1, ans = 0, ans2 = 0, q = 0, c1 = 0, c2 = 0, n = 1, m = 0, x = -133; cin >> a; std::vector<long long int> v(a); for (int i = 0; i < a; ++i) { cin >> v[i]; if (v[i] > x) { x = v[i]; } t += v[i]; } ans = t / (a - 1) + 1 * (bool)(t % (a - 1)); ans2 = x; cout << max(ans2, ans); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); clock_t z = clock(); long long int qc = 1; for (long long int i = 1; i <= qc; i++) solve(); fprintf(stderr, "Total Time: % .4Lf\n", (long double)(clock() - z) / CLOCKS_PER_SEC), fflush(stderr); }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long n, a, mx = 0; cin >> n; vector<long long> vc(n); for (size_t i = 0; i < n; i++) { cin >> a; vc[i] = a; mx = max(a, mx); } long long sm = 0; for (auto& i : vc) { sm += mx - i; } cout << mx + (max(static_cast<long long>(0), (mx - sm + n - 2)) / (n - 1)) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, a[100005]; void citeste() { cin >> n; for (int i = 1; i <= n; ++i) { int first; cin >> a[i]; } } void rezolva() { long long sum = 0LL; sort(a + 1, a + n + 1); for (int i = 2; i <= n; ++i) { sum += (a[n] - a[i]); } if (a[1] <= sum) { cout << a[n] << "\n"; return; } a[1] = a[1] - sum; cout << a[n] + a[1] / (n - 1) + (bool)(a[1] % (n - 1)); } int main() { citeste(); rezolva(); return 0; }
#include <bits/stdc++.h> using namespace std; bool cmp(const pair<int, int>& p1, const pair<int, int>& p2) { return p1.first < p2.first; } long long int in[100005]; int main() { double n; cin >> n; double s = 0; double ans = 0; for (int i = 0; i < n; i++) { double a; cin >> a; s += a; if (ans < a) ans = a; } ans = max(ans, ceil(s / (n - 1))); printf("%0.0lf\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) { return a; } return gcd(b, a % b); } long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long n; cin >> n; long long maximum = 0, sum = 0; for (long long i = 0; i < n; i++) { long long temp; cin >> temp; sum += temp; maximum = max(maximum, temp); } long long ans = ceil((sum * 1.00) / ((n - 1) * 1.00)); ans = max(ans, maximum); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; const int Maxn = 200005; const int oo = 1000000007; typedef int Tarr[Maxn]; Tarr a; long long low, high, mid; int n; bool Ok(long long x) { long long sum = 0; for (int i = 1; i <= n; i++) { sum += (long long)(x - a[i]); if (sum >= x) return true; } if (sum >= x) return true; else return false; } int main() { scanf("%d/n", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); sort(a + 1, a + n + 1); low = (long long)a[n]; high = (long long)100 * oo; while (low + 1 < high) { mid = (low + high) / 2; if (Ok(mid)) high = mid; else low = mid; } if (Ok(low)) cout << low << endl; else cout << high << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 100100; string s[1000]; int main() { long long n, m[100010]; cin >> n; for (int i = 0; i < n; i++) cin >> m[i]; sort(m, m + n); long long s = 0; for (int i = 0; i < n; i++) s += m[i]; cout << max(m[n - 1], (long long)ceil((long double)s / (long double)(n - 1))); }
#include <bits/stdc++.h> using namespace std; long long int arr[100005], dp[1000005], res[100005]; bool vis[100005]; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long int n, ans = 0, maxele = INT_MIN, sum = 0; cin >> n; for (long long int i = 0; i < n; i++) { cin >> arr[i]; maxele = max(maxele, arr[i]); sum += arr[i]; } n--; sum = sum / n + (sum % n ? 1 : 0); cout << max(maxele, sum); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; long long vec[100100]; scanf("%d", &n); long long suma = 0; long long m = -1; for (int i = 0; i < n; i++) { scanf("%lld", &vec[i]); suma += vec[i]; if (vec[i] > m) m = vec[i]; } sort(vec, vec + n); long long menor = 0; long long mayor = 1000000000000; long long mid; while (menor < mayor) { mid = menor + (mayor - menor) / 2; suma = 0; for (int i = 0; i < n; i++) { suma += mid - vec[i]; } if (suma >= mid && mid >= m) { mayor = mid; } else { menor = mid + 1; mid += 1; } } printf("%lld", mid); return 0; }
#include <bits/stdc++.h> using namespace std; static int a[100000], n; static long long ma, si; int main() { scanf("%d", &n); for (register int i = 0; i < n; ++i) scanf("%d", a + i), ma = max(int(ma), a[i]), si += a[i]; long long ans = 0, mid, l = ma, r = si; while (l <= r) { mid = l + r >> 1; if (mid * (n - 1) >= si) ans = mid, r = mid - 1; else l = mid + 1; } printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int arr[n], mx = 0, x; long long int s = 0; for (int i = 0; i < n; i++) { cin >> x; if (x > mx) mx = x; s += x; } cout << max((s - 1) / (n - 1) + 1, mx); }
#include <bits/stdc++.h> using namespace std; const long long MXN = 1e6 + 1; const long long MNN = 1e3 + 1; const long long MOD = 1e9 + 7; const long long INF = 1e18; const long long MAGIC = 1000; const long double EPS = 1e-9; const long double PI = 3.1415926536; const string TIME = "rovno_ushten_push_ketti"; long long n; long long a[MXN]; long long ok(long long x) { long long sum = 0; for (long long i = 1; i <= n; i++) { if (a[i] > x) { return 0; } sum += (x - a[i]); } return (sum >= x); } int main() { scanf("%I64d", &n); for (long long i = 1; i <= n; i++) { scanf("%I64d", a + i); } long long l = 0, r = 10000000000; while (r - l > 1) { long long mid = (l + r) / 2; if (ok(mid)) { r = mid; } else { l = mid; } } printf("%I64d", r); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); long long int n; cin >> n; long long int a[n]; long long int mx = 0; long long int sum = 0; for (long long int i = 0; i < n; i++) { cin >> a[i]; mx = max(mx, a[i]); sum += a[i]; } long long int aa = sum; long long int bb = n - 1; long long int ans = (aa + bb - 1) / (bb); cout << max(ans, mx) << '\n'; }
#include <bits/stdc++.h> using namespace std; long long n, b[1005000], m, sum; long long a[1005000]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i], m = max(m, a[i]), sum += a[i]; if (m * n - sum >= m) cout << m; else cout << (sum + n - 2) / (n - 1); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); long long sum = n - 2, x, ub = 0; for (int i = 0; i < n; i++) { scanf("%I64d", &x); ub = max(ub, x); sum += x; } printf("%I64d\n", max(sum / (n - 1), ub)); return 0; }
#include <bits/stdc++.h> using namespace std; void input() { int i, n, x, xmax = 0; long long tt = 0; scanf("%d", &n); for ((i) = 0; (i) < (n); (i)++) scanf("%d", &x), tt += x, xmax = ((xmax) > (x) ? (xmax) : (x)); long long dau = xmax, cuoi = tt, giua; while (dau <= cuoi) { giua = (dau + cuoi) >> 1; if (giua * (n - 1) >= tt) cuoi = giua - 1; else dau = giua + 1; } printf("%I64d", dau); } int main() { input(); return 0; }
#include <bits/stdc++.h> using namespace std; bool isPossible(long long int x, long long int a[], long long int n) { long long int supin, tot = 0; for (long long int i = 0; i < n; i++) { supin = 0; if (x - a[i] >= 0) supin = x - a[i]; tot += supin; } if (tot >= x) return true; return false; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, a[100001]; cin >> n; for (long long int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); long long int s = a[n - 1]; long long int e = a[0] + a[n - 1]; long long int ans = 0; while (s <= e) { long long int mid = (s + e) / 2; if (isPossible(mid, a, n) == true) { e = mid - 1; ans = mid; } else { s = mid + 1; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; long long int a[100005]; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); ; long long int n, sum, mx = 0; sum = 0; cin >> n; for (long long int i = 0; i <= n - 1; i++) cin >> a[i]; for (long long int i = 0; i <= n - 1; i++) { mx = max(mx, a[i]); sum += a[i]; } cout << max((sum + n - 2) / (n - 1), mx) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, a, s, m; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a, m = max(a, m), s += a; cout << max(m, (s - 1) / (n - 1) + 1); return 0; }
#include <bits/stdc++.h> using namespace std; const long long int MOD = 1e9 + 7; const long long int inf = 1e18; long long int arr[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, i, sum1 = 0, res, max1 = -inf; cin >> n; for (i = 0; i < n; i++) { cin >> arr[i]; if (max1 < arr[i]) max1 = arr[i]; } for (i = 0; i < n; i++) sum1 += arr[i]; res = (long long int)ceil((long double)sum1 / (n - 1)); cout << max(res, max1) << endl; cerr << "Time Taken:" << (float)clock() / CLOCKS_PER_SEC * 1000 << "ms" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, mid, mx = -INT_MAX, sum = 0; cin >> n; for (int i = 1; i <= n; i++) cin >> mid, mx = max(mx, mid), sum += mid; cout << max((sum - 1) / (n - 1) + 1, mx) << endl; }
#include <bits/stdc++.h> using namespace std; long long n, m, k, i, j, res; long long a[100001]; int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; m += a[i]; } sort(a + 1, a + n + 1); cout << max(a[n], (m + n - 2) / (n - 1)); }
#include <bits/stdc++.h> long long A[100010]; int n; bool can(long long k) { long long co = 0; for (int c = 1; c <= n; c++) { if (k - A[c] < 0) return false; co += k - A[c]; } if (co >= k) return true; return false; } long long bs(long long st, long long ed) { if (st >= ed) return st; int mid = (st + ed) / 2; if (can(mid)) return bs(st, mid); return bs(mid + 1, ed); } int main() { scanf("%d", &n); for (int c = 1; c <= n; c++) scanf("%I64d", &A[c]); printf("%I64d", bs(1, 2000000000)); }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long s = 0; long long mx = (long long)-2e9; for (int i = 0, x; i < n; i++) cin >> x, s += x, mx = max(mx, x * 1LL); cout << max((s + n - 2) / (n - 1), mx) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n; long long sum, mx; int main() { cin >> n; long long a; for (int i = 0; i < n; i++) { cin >> a; sum += a; mx = max(mx, a); } cout << max(mx, (sum - 1) / (n - 1) + 1) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long a[101010]; int n; long long ans = 0; bool cheak(int x) { long long temp; long long tot = 0; for (int i = 1; i < n; i++) { temp = x - a[i]; if (temp < 0) return false; tot += temp; } if (tot >= a[n]) return true; return false; } int main() { while (scanf("%d", &n) != EOF) { for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]); long long l = 1, r = 2000000000; long long mid; while (l < r - 1) { mid = (l + r) >> 1; if (cheak(mid)) r = mid; else l = mid; } ans = r; printf("%I64d\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; int aa[100005]; long long int max(long long int aaa, long long int bbb) { if (aaa > bbb) return aaa; return bbb; } int main() { int n; cin >> n; long long sum = 0; long long int mx = 0; for (int i = 1; i <= n; i++) cin >> aa[i], sum += aa[i], mx = max(aa[i], mx); n = n - 1; long long ans; ans = sum / n; if (sum % n != 0) ans++; cout << max(mx, ans) << endl; }
#include <bits/stdc++.h> using namespace std; const int N = 1000 * 100 + 5; long long n, maxim, sum; int main() { cin >> n; for (long long i = 0, tmp; i < n; i++) cin >> tmp, sum += tmp, maxim = max(maxim, tmp); cout << max(maxim, (sum + n - 2) / (n - 1)) << '\n'; }
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, mx = 0; long long sum = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; mx = max(mx, a[i]); } int ans = (sum + (n - 1) - 1) / (n - 1); if (ans < mx) { cout << mx; } else { cout << ans; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long sum = 0; int max = 0; for (int i = 0; i < n; i++) { int c; cin >> c; sum += c; if (c > max) max = c; } int res = sum / (n - 1); if (sum % (n - 1)) res++; if (res < max) res = max; cout << res; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int a[n + 1]; long long int sum = 0; for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i]; long long int maxx = *max_element(a + 1, a + n + 1); long long int x = sum / (n - 1); if (sum % (n - 1)) x++; cout << max(maxx, x); return 0; }
#include <bits/stdc++.h> int a[100010]; int main(int argc, char *argv[]) { int i, n; while (scanf("%d", &n) != EOF) { long long sum = 0; long long max = 0; for (i = 0; i < n; ++i) { scanf("%d", &a[i]); sum += a[i]; if (a[i] > max) { max = a[i]; } } long long r = sum / (n - 1); if (sum % (n - 1) != 0) { ++r; } if (max > r) { printf("%I64d\n", max); } else { printf("%I64d\n", r); } } return 0; }
#include <bits/stdc++.h> using namespace std; long long arr[1000000]; int main() { long long n; cin >> n; long long maxi = 0; for (long long i = 0; i < n; i++) { cin >> arr[i]; if (maxi < arr[i]) maxi = arr[i]; } long long tot = 0; for (long long i = 0; i < n; i++) tot += maxi - arr[i]; long long l = maxi - tot; if (tot >= maxi) cout << maxi; else { long long k = l / (n - 1); if (l % (n - 1) != 0) k++; cout << k + maxi; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long t = 0, i, j, n; long long arr[100002]; cin >> n; for (i = 0; i < n; ++i) { cin >> arr[i]; t += arr[i]; } if (t % (n - 1) == 0) { j = t / (n - 1); } else { j = t / (n - 1) + 1; } long long mx = *max_element(arr, arr + n); cout << max(mx, j); return 0; }
#include <bits/stdc++.h> using namespace std; long long A[100006], n; bool isPossible(long long r) { long long sum = 0; for (long long i = 0; i < n; i++) { sum += (r - A[i]); } if (sum >= r) { return true; } return false; } int main() { long long high = 0, low = 0; cin >> n; for (long long i = 0; i < n; i++) { cin >> A[i]; high += A[i]; low = max(low, A[i]); } long long ans = high; while (low <= high) { long long mid = (low + high) / 2; if (isPossible(mid)) { ans = mid; high = mid - 1; } else { low = mid + 1; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; int a[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; long long sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } cout << max(1LL * *max_element(a, a + n), (sum + n - 2) / (n - 1)) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long num, tmp, sum, mx, l, r, mid; cin >> num; mx = sum = 0; for (int i = 0; i < num; i++) { cin >> tmp; sum += tmp; mx = max(mx, tmp); } l = mx; r = sum; while (l < r) { mid = (l + r) / 2; if (mid * num - sum >= mid) r = mid; else l = mid + 1; } cout << l; return 0; }