結果
| 問題 |
No.2890 Chiffon
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-14 04:34:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 243 ms / 2,000 ms |
| コード長 | 832 bytes |
| コンパイル時間 | 2,042 ms |
| コンパイル使用メモリ | 196,344 KB |
| 最終ジャッジ日時 | 2025-02-24 08:25:30 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 53 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,K; cin >> N >> K;
vector<int> A(K);
for(auto &a : A) cin >> a;
for(int i=0; i<K; i++) A.push_back(A.at(i)+2*N);
int answer = 0;
for(int i=0; i<=2*N/K+1; i+=2){
int low = 1,high = N;
while(high-low > 1){
int mid = (high+low)/2;
int now = 0,pos = i;
while(now < K){
int apos = upper_bound(A.begin(),A.end(),pos)-A.begin();
int next = max(A.at(apos)+1,pos+mid*2);
if(next > i+2*N) break;
now++; pos = next;
}
if(now == K) low = mid;
else high = mid;
}
answer = max(answer,low*2);
}
cout << answer << endl;
}