結果
問題 | No.2890 Chiffon |
ユーザー |
|
提出日時 | 2024-09-13 21:43:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 740 bytes |
コンパイル時間 | 765 ms |
コンパイル使用メモリ | 64,256 KB |
実行使用メモリ | 9,216 KB |
最終ジャッジ日時 | 2024-09-26 14:33:22 |
合計ジャッジ時間 | 2,709 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 53 |
ソースコード
#include<iostream> #include<cassert> using namespace std; int N,K; int A[1500000]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>K; for(int i=0;i<K;i++) { cin>>A[i],A[i]--; A[i+K]=A[i]+N+N; A[i+K+K]=A[i]+N+N+N+N; } int idx=-1; { int W=1e9; for(int i=0;i<K;i++) { int w=A[i+1]-A[i]; if(W>w)W=w,idx=i; } } int l=0,r=N; while(r-l>1) { int m=(l+r)/2; bool ok=false; for(int s=A[idx]+1;s<A[idx+1];s+=2) { int u=s; bool now=true; for(int j=1;j<=K;j++) { int nu=max(u+m+m,A[idx+j]+1); if(nu>A[idx+j+1]) { now=false; break; } u=nu; } if(now&&u<=s+N+N) { ok=true; break; } } if(ok)l=m; else r=m; } cout<<l+l<<endl; }