結果
| 問題 | No.3513 Greedy Yokan Party |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-24 21:37:10 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1,034 ms / 2,000 ms |
| コード長 | 678 bytes |
| 記録 | |
| コンパイル時間 | 2,947 ms |
| コンパイル使用メモリ | 339,644 KB |
| 実行使用メモリ | 15,104 KB |
| 最終ジャッジ日時 | 2026-04-24 21:37:25 |
| 合計ジャッジ時間 | 13,398 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
ll l;
cin>>n>>l;
int k;
cin>>k;
vector<ll> a(n+2);
for(int i=0;i<n;i++)cin>>a[i+1];
a[n+1]=l;
ll ok=0,ng=l;
k++;
while(ok+1<ng){
ll c=(ok+ng)/2;
vector<vector<int>> dp(k+1,vector<int>(3,n+2));
dp[0][0]=0;
for(int i=0;i<k;i++){
for(int j=0;j<3;j++){
if(dp[i][j]==n+2)continue;
dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1);
if(j<2){
auto itr=ranges::lower_bound(a,a[dp[i][j]]+c);
dp[i+1][j+1]=min(dp[i+1][j+1],(int)(itr-a.begin()));
}
}
}
if(dp[k][2]<=n+1)ok=c;
else ng=c;
}
cout<<ok<<endl;
}