結果
| 問題 |
No.2217 Suffix+
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2023-02-17 21:32:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 139 ms / 2,000 ms |
| コード長 | 773 bytes |
| コンパイル時間 | 4,427 ms |
| コンパイル使用メモリ | 250,828 KB |
| 最終ジャッジ日時 | 2025-02-10 16:24:36 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
int main(){
long long N,K;
cin>>N>>K;
vector<long long> a(N);
rep(i,N){
cin>>a[i];
}
long long ok = 0,ng = 1000000000000000;
while(ng-ok>1LL){
long long mid = (ok+ng)/2;
long long cnt = 0,sum = 0;
bool f = true;
rep(i,N){
if(cnt > K)break;
if(sum >= mid)break;
long long ca = a[i] + sum;
if(ca>=mid)continue;
ca = mid - ca;
long long t = i+1;
cnt += (ca+t-1) / t;
sum += ((ca+t-1) / t) * t;
}
if(cnt <= K)ok = mid;
else ng = mid;
}
cout<<ok<<endl;
return 0;
}
沙耶花