結果
| 問題 |
No.2217 Suffix+
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2023-08-29 11:34:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 771 bytes |
| コンパイル時間 | 1,763 ms |
| コンパイル使用メモリ | 167,428 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-30 23:19:33 |
| 合計ジャッジ時間 | 5,020 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 WA * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
long long n, k, a[MAXN], mins = 1e18, b[MAXN];
bool F(long long x){
for(int i = 1; i <= n; i++){
if(a[i] < x){
b[i] = x - a[i];
} else {
b[i] = 0;
}
}
long long xx = 0, s = 0;
for(int i = 1; i <= n; i++){
if(b[i]){
b[i] -= s;
if(b[i]){
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]);
}
long long l = 0, r = mins + k * n;
while(l < r){
long long mid = (l + r + 1) >> 1;
if(F(mid)){
l = mid;
} else {
r = mid - 1;
}
}
cout << l;
return 0;
}
vjudge1