提出 #7624922


ソースコード 拡げる

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
long long A[50];
int main(){
  int i;
  int j;
  int fg;
  long long res = 0;
  long long t;
  long long s;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(;;){
    s = 0;
    for(i=(0);i<(N);i++){
      t = A[i] / N;
      s += t;
      A[i] -= t * (N+1);
    }
    if(s==0){
      break;
    }
    res += s;
    for(i=(0);i<(N);i++){
      A[i] += s;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190921-1

// --- original code ---
// int N; ll A[50];
// {
//   int i, j, fg;
//   ll res = 0, t, s;
//   rd(N,A(N));
//   for(;;){
//     s = 0;
//     rep(i,N){
//       t = A[i] / N;
//       s += t;
//       A[i] -= t * (N+1);
//     }
//     if(s==0) break;
//     res += s;
//     rep(i,N) A[i] += s;
//   }
//   wt(res);
// }

提出情報

提出日時
問題 E - Decrease (Judge ver.)
ユーザ LayCurse
言語 C++14 (GCC 5.4.1)
得点 600
コード長 2016 Byte
結果 AC
実行時間 2 ms
メモリ 256 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 5
AC × 35
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
example0 AC 1 ms 256 KiB
example1 AC 1 ms 256 KiB
example2 AC 1 ms 256 KiB
example3 AC 1 ms 256 KiB
example4 AC 1 ms 256 KiB
maxrand0 AC 1 ms 256 KiB
maxrand1 AC 2 ms 256 KiB
maxrand2 AC 1 ms 256 KiB
maxrand3 AC 2 ms 256 KiB
maxrand4 AC 1 ms 256 KiB
maxrand5 AC 2 ms 256 KiB
maxrand6 AC 1 ms 256 KiB
maxrand7 AC 2 ms 256 KiB
maxrand8 AC 1 ms 256 KiB
maxrand9 AC 2 ms 256 KiB
rand0 AC 1 ms 256 KiB
rand1 AC 1 ms 256 KiB
rand2 AC 1 ms 256 KiB
rand3 AC 2 ms 256 KiB
rand4 AC 1 ms 256 KiB
rand5 AC 1 ms 256 KiB
rand6 AC 1 ms 256 KiB
rand7 AC 2 ms 256 KiB
rand8 AC 1 ms 256 KiB
rand9 AC 1 ms 256 KiB
small0 AC 1 ms 256 KiB
small1 AC 1 ms 256 KiB
small2 AC 1 ms 256 KiB
small3 AC 1 ms 256 KiB
small4 AC 1 ms 256 KiB
small5 AC 1 ms 256 KiB
small6 AC 1 ms 256 KiB
small7 AC 1 ms 256 KiB
small8 AC 1 ms 256 KiB
small9 AC 1 ms 256 KiB