結果

問題 No.2890 Chiffon
ユーザー Jeroen Op de Beek
提出日時 2024-09-13 21:40:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,316 bytes
コンパイル時間 1,933 ms
コンパイル使用メモリ 196,520 KB
最終ジャッジ日時 2025-02-24 07:21:48
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define all(x) x.begin(),x.end()
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << " " << p.second; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#define ASSERT(...) 42
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int oo = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k; cin >> n >> k;
    vi a(k);
    for(auto& i : a) cin >> i;
    for(int i=0;i<k;++i) a.push_back(a[i]+2*n);
    int lo = 0, hi = n*2;
    auto good = [&](int mid) {
        ll worst = -1e9;
        for(int i=0;i<2*k;++i) {
            if(worst>=a[i]) {
                // bad!
                return false;
            }
            worst = max(worst+mid,(ll)a[i]+1);
        }
        return true;
    };
    while(lo<hi) {
        int mid = (lo+hi+1)/2;
        if(good(mid)) lo = mid;
        else hi = mid-1;
    }
    cout << lo << '\n';
}
0