結果

問題 No.2217 Suffix+
ユーザー vjudge1vjudge1
提出日時 2023-08-29 12:28:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,000 bytes
コンパイル時間 2,071 ms
コンパイル使用メモリ 199,648 KB
実行使用メモリ 6,716 KB
最終ジャッジ日時 2023-08-29 12:28:36
合計ジャッジ時間 5,080 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 11 ms
4,380 KB
testcase_15 AC 11 ms
4,384 KB
testcase_16 AC 21 ms
5,088 KB
testcase_17 AC 15 ms
4,600 KB
testcase_18 AC 12 ms
4,380 KB
testcase_19 AC 75 ms
5,864 KB
testcase_20 AC 72 ms
5,496 KB
testcase_21 AC 14 ms
4,376 KB
testcase_22 AC 76 ms
5,956 KB
testcase_23 AC 66 ms
5,088 KB
testcase_24 AC 35 ms
6,556 KB
testcase_25 AC 36 ms
6,536 KB
testcase_26 AC 38 ms
6,492 KB
testcase_27 AC 36 ms
6,444 KB
testcase_28 AC 37 ms
6,716 KB
testcase_29 AC 111 ms
6,584 KB
testcase_30 AC 116 ms
6,404 KB
testcase_31 AC 112 ms
6,508 KB
testcase_32 AC 114 ms
6,656 KB
testcase_33 AC 113 ms
6,432 KB
testcase_34 AC 37 ms
6,488 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 140 ms
6,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int __int128

using namespace std;
const int MAXN = 1e5 + 5;
int n, k, a[MAXN], minn = 1e22, b[MAXN];
int read(){
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++){
    cnt = cnt * 10 + s[i] - '0';
  }
  return cnt;
}
void print(int x){
  if (x < 10){
    signed p = x;
    cout << p;
    return ;
  }
  print(x / 10);
  signed p = x % 10;
  cout << p;
}
bool check(int x){
  int p = 0, q = 0;
  for (int i = 1; i <= n; i++){
    b[i] = max(int(0), x - a[i]);
  }
  for (int i = 1; i <= n; i++){
    if (b[i] > q){
      p += (b[i] - q + i - 1) / i;
      q += (b[i] - q + i - 1) / i * i;
    }
  }
  return p <= k;
}
signed main(){
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  n = read(), k = read();
  for (int i = 1; i <= n; i++){
    a[i] = read();
  }
  int l = 0, r = 1e20;
  while (l < r){
    int mid = (l + r + 1) >> 1;
    if (check(mid)){
      l = mid;
    }else {
      r = mid - 1;
    }
  }
  print(l);
  return 0;
}//
0