結果
| 問題 |
No.2217 Suffix+
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2023-08-29 10:49:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 133 ms / 2,000 ms |
| コード長 | 595 bytes |
| コンパイル時間 | 2,361 ms |
| コンパイル使用メモリ | 189,740 KB |
| 最終ジャッジ日時 | 2025-02-16 15:28:22 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int MAXN = 1e5 + 3;
int n;
LL k, a[MAXN];
bool as(LL MIN){
LL _k = k;
for(LL i = 1, s = 0; i <= n; i++){
if(a[i] + s < MIN){
LL cnt = (MIN - (a[i] + s) + i - 1) / i;
_k -= cnt;
if(_k < 0) return 0;
s += cnt * i;
}
}
return 1;
}
int main(){
cin >> n>> k;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
LL l = 0, r = 1e17;
while(l < r){
LL mid = (l + r + 1) >> 1;
if(as(mid)){
l = mid;
}else{
r = mid - 1;
}
}
cout << l;
return 0;
}
vjudge1