結果
| 問題 |
No.2217 Suffix+
|
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2023-02-17 21:38:36 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 106 ms / 2,000 ms |
| コード長 | 744 bytes |
| コンパイル時間 | 891 ms |
| コンパイル使用メモリ | 28,928 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 12:45:16 |
| 合計ジャッジ時間 | 2,320 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include <stdio.h>
int main () {
int n = 0;
long long k = 0LL;
long long a[100000] = {};
int res = 0;
long long ans[2] = { 0LL, 1000000000000000LL };
res = scanf("%d", &n);
res = scanf("%lld", &k);
for (int i = 0; i < n; i++) {
res = scanf("%lld", a+i);
}
while (ans[1]-ans[0] > 1LL) {
long long nxt = (ans[0]+ans[1])/2LL;
long long cnt = 0LL;
long long sum = 0LL;
for (int i = 0; i < n; i++) {
if (a[i]+sum < nxt) {
long long tmp = 1LL+(nxt-a[i]-sum-1LL)/((long long)(i+1));
cnt += tmp;
sum += tmp*((long long)(i+1));
}
}
if (cnt <= k) {
ans[0] = nxt;
} else {
ans[1] = nxt;
}
}
printf("%lld\n", ans[0]);
return 0;
}
chro_96