Submission #3050596


Source Code Expand

#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 50;
const ll INF = 1e18;
int N;
ll a[MAX_N];

int main() {
  cin >> N;
  rep(i, N) cin >> a[i];

  ll lb = -1, ub = INF, mid;
  while (ub-lb > 1) {
    mid = (ub+lb)/2;
    ll k = 0;
    for (int i = 0; i < N; ++i) {
      k += (a[i]+mid+1)/(N+1);
    }
    if (k <= mid) ub = mid;
    else lb = mid;
  }

  ll ans = ub;
  for (ll i = lb; i >= lb-2*N && i >= 0; --i) {
    ll k = 0;
    for (int j = 0; j < N; ++j) {
      k += (a[j]+i+1)/(N+1);
    }
    if (k <= i) ans = i;
  }

  cout << ans << endl;

  return 0;
}

Submission Info

Submission Time
Task E - Decrease (Judge ver.)
User Bobyama
Language C++14 (Clang 3.8.0)
Score 0
Code Size 1088 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 5
AC × 25
WA × 10
Set Name Test Cases
Sample example0, example1, example2, example3, example4
All example0, example1, example2, example3, example4, maxrand0, maxrand1, maxrand2, maxrand3, maxrand4, maxrand5, maxrand6, maxrand7, maxrand8, maxrand9, rand0, rand1, rand2, rand3, rand4, rand5, rand6, rand7, rand8, rand9, small0, small1, small2, small3, small4, small5, small6, small7, small8, small9
Case Name Status Exec Time Memory
example0 AC 1 ms 256 KB
example1 AC 1 ms 256 KB
example2 AC 1 ms 256 KB
example3 AC 1 ms 256 KB
example4 AC 1 ms 256 KB
maxrand0 AC 1 ms 256 KB
maxrand1 WA 1 ms 256 KB
maxrand2 AC 1 ms 256 KB
maxrand3 WA 1 ms 256 KB
maxrand4 AC 1 ms 256 KB
maxrand5 WA 1 ms 256 KB
maxrand6 AC 1 ms 256 KB
maxrand7 WA 1 ms 256 KB
maxrand8 AC 1 ms 256 KB
maxrand9 WA 1 ms 256 KB
rand0 AC 1 ms 256 KB
rand1 AC 1 ms 256 KB
rand2 WA 1 ms 256 KB
rand3 AC 1 ms 256 KB
rand4 AC 1 ms 256 KB
rand5 AC 1 ms 256 KB
rand6 AC 1 ms 256 KB
rand7 WA 1 ms 256 KB
rand8 AC 1 ms 256 KB
rand9 AC 1 ms 256 KB
small0 AC 1 ms 256 KB
small1 WA 1 ms 256 KB
small2 AC 1 ms 256 KB
small3 WA 1 ms 256 KB
small4 AC 1 ms 256 KB
small5 AC 1 ms 256 KB
small6 AC 1 ms 256 KB
small7 AC 1 ms 256 KB
small8 AC 1 ms 256 KB
small9 WA 1 ms 256 KB