結果
| 問題 | No.3513 Greedy Yokan Party |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-24 21:42:17 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 108 ms / 2,000 ms |
| コード長 | 1,004 bytes |
| 記録 | |
| コンパイル時間 | 2,144 ms |
| コンパイル使用メモリ | 216,180 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-24 21:42:34 |
| 合計ジャッジ時間 | 7,099 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,L; cin >> N >> L;
int K; cin >> K;
vector<int> A(N);
for(auto &a : A) cin >> a;
A.insert(A.begin(),0);
A.push_back(L);
N++;
int low = 0,high = 1001001001;
while(high-low > 1){
int mid = (high+low)/2;
vector<int> To(N,-1),C(N,N+1);
int pos = 0;
for(int i=0; i<N; i++){
while(pos <= N && A.at(i)+mid > A.at(pos)) pos++;
if(pos > N) break;
To.at(i) = pos;
C.at(i) = pos-i;
}
for(int i=N-2; i>=0; i--) C.at(i) = min(C.at(i),C.at(i+1));
bool ok = false;
for(int i=0; i<N; i++){
int to = To.at(i);
if(to == -1 || to == N) continue;
int use = to-i+C.at(to);
if(use+K-1 <= N){ok = true; break;}
}
if(ok) low = mid;
else high = mid;
}
cout << low << endl;
}