AtCoder Regular Contest 079

Submission #1470226

Source codeソースコード

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, A[50];

bool ok(ll k) {
  ll sum = 0;
  REP(i, 0, N) if(A[i] + k >= N) sum += (A[i] + k - N) / (N + 1) + 1;
  return sum <= k;
}

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> A[i];

  bool f = true;
  REP(i, 0, N) f = f && (A[i] < N);
  if(!f) {
    ll l = 0, h = (1LL << 60);
    while(l + 100000 < h) {
      ll m = (l + h) / 2;
      if(ok(m)) h = m;
      else l = m;
    }
    ll ans;
    REP(i, l, h + 1) {
      if(ok(i)) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
}

Submission

Task問題 E - Decrease (Judge ver.)
User nameユーザ名 Shinya Kato
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 600
Source lengthソースコード長 778 Byte
File nameファイル名
Exec time実行時間 25 ms
Memory usageメモリ使用量 256 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - example0,example1,example2,example3,example4
All 600 / 600 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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 2 ms 256 KB
maxrand0 AC 2 ms 256 KB
maxrand1 AC 25 ms 256 KB
maxrand2 AC 2 ms 256 KB
maxrand3 AC 16 ms 256 KB
maxrand4 AC 2 ms 256 KB
maxrand5 AC 25 ms 256 KB
maxrand6 AC 4 ms 256 KB
maxrand7 AC 24 ms 256 KB
maxrand8 AC 5 ms 256 KB
maxrand9 AC 8 ms 256 KB
rand0 AC 5 ms 256 KB
rand1 AC 7 ms 256 KB
rand2 AC 13 ms 256 KB
rand3 AC 11 ms 256 KB
rand4 AC 8 ms 256 KB
rand5 AC 7 ms 256 KB
rand6 AC 4 ms 256 KB
rand7 AC 20 ms 256 KB
rand8 AC 7 ms 256 KB
rand9 AC 13 ms 256 KB
small0 AC 1 ms 256 KB
small1 AC 1 ms 256 KB
small2 AC 1 ms 256 KB
small3 AC 1 ms 256 KB
small4 AC 1 ms 256 KB
small5 AC 2 ms 256 KB
small6 AC 1 ms 256 KB
small7 AC 1 ms 256 KB
small8 AC 2 ms 256 KB
small9 AC 2 ms 256 KB