結果

問題 No.2217 Suffix+
ユーザー vjudge1vjudge1
提出日時 2024-02-22 10:53:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 917 bytes
コンパイル時間 2,491 ms
コンパイル使用メモリ 201,400 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-22 10:54:01
合計ジャッジ時間 6,773 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 37 ms
6,676 KB
testcase_15 AC 37 ms
6,676 KB
testcase_16 AC 77 ms
6,676 KB
testcase_17 AC 56 ms
6,676 KB
testcase_18 AC 46 ms
6,676 KB
testcase_19 AC 113 ms
6,676 KB
testcase_20 AC 95 ms
6,676 KB
testcase_21 AC 15 ms
6,676 KB
testcase_22 AC 103 ms
6,676 KB
testcase_23 AC 76 ms
6,676 KB
testcase_24 AC 150 ms
6,676 KB
testcase_25 AC 155 ms
6,676 KB
testcase_26 AC 156 ms
6,676 KB
testcase_27 AC 154 ms
6,676 KB
testcase_28 AC 179 ms
6,676 KB
testcase_29 AC 152 ms
6,676 KB
testcase_30 AC 152 ms
6,676 KB
testcase_31 AC 156 ms
6,676 KB
testcase_32 AC 156 ms
6,676 KB
testcase_33 AC 153 ms
6,676 KB
testcase_34 AC 158 ms
6,676 KB
testcase_35 AC 2 ms
6,676 KB
testcase_36 AC 154 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

using LL = long long;

const int N = 1e5 + 5;

LL c[N], ok, sum, a[N], now, n, k, l, r, mid, ans;

LL lowbit(LL x){
  return x & -x;
}

LL getsum(LL x){
  for(ans = 0; x > 0; ans += c[x], x -= lowbit(x)){
  }
  return ans;
}

void updata(int i, LL k){
  for(; i <= n; c[i] += k, i += lowbit(i)){
  }
}

bool C(LL x){
  for(int i = 1; i <= n; ++i){
    c[i] = 0;
  }
  for(int i = 1; i <= n; ++i){
    //updata(i, a[i] - a[i - 1]);
  }
  sum = ans = 0;
  for(int i = 1; i <= n; ++i){
    //now = getsum(i);
    ok = max(0ll, (x - (a[i] + ans) + i - 1) / i);
    sum += ok;
    ans += ok * i;
  }
  return sum <= k;
}

int main(){
  cin >> n >> k;
  for(int i = 1; i <= n; ++i){
    cin >> a[i];
  }
  l = 0, r = (LL)(2e14);
  while(l < r){
    mid = (l + r + 1) >> 1;
    if(C(mid)){
      l = mid;
    }
    else{
      r = mid - 1;
    }
  }
  cout << l;
  return 0;
}
0