結果

問題 No.2217 Suffix+
ユーザー vjudge1vjudge1
提出日時 2023-08-29 11:38:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 164,596 KB
実行使用メモリ 5,272 KB
最終ジャッジ日時 2023-08-29 11:38:49
合計ジャッジ時間 4,736 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 90 ms
4,596 KB
testcase_20 AC 71 ms
4,384 KB
testcase_21 AC 11 ms
4,380 KB
testcase_22 AC 82 ms
4,480 KB
testcase_23 AC 61 ms
4,464 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 99 ms
4,852 KB
testcase_30 AC 99 ms
5,024 KB
testcase_31 AC 100 ms
4,872 KB
testcase_32 AC 97 ms
4,896 KB
testcase_33 AC 95 ms
4,884 KB
testcase_34 AC 62 ms
5,024 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 120 ms
4,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;

unsigned long long n, k, a[MAXN], mins = 1e18, b[MAXN];

bool F(unsigned long long x){
  for(int i = 1; i <= n; i++){
    if(a[i] < x){
      b[i] = x - a[i];
    } else {
      b[i] = 0;
    }
  }
  unsigned long long xx = 0, s = 0;
  for(int i = 1; i <= n; i++){
    if(b[i]){
      b[i] -= s;
      if(b[i] > 0){
        xx += (b[i] + i - 1) / i;
        s += (b[i] + i - 1) / i * i;
      }
    }
  }
  return xx <= k;
}

int main(){
  cin >> n >> k;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    mins = min(mins, a[i]);
  }
  unsigned long long l = 0, r = mins + k * n;
  while(l < r){
    unsigned long long mid = (l + r + 1) >> 1;
    if(F(mid)){
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  cout << l;
  return 0;
}
0