結果

問題 No.2890 Chiffon
ユーザー Fu_LFu_L
提出日時 2024-09-26 09:35:39
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,411 bytes
コンパイル時間 4,921 ms
コンパイル使用メモリ 275,488 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-09-26 09:35:49
合計ジャッジ時間 9,168 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
int main(void) {
    int n, k;
    cin >> n >> k;
    n *= 2;
    vector<int> a(2 * k);
    rep(i, 0, k) {
        cin >> a[i];
        a[k + i] = a[i] + n;
    }
    int mi = 1e9, s = -1;
    rep(i, 0, 2 * k - 1) {
        if(a[i + 1] - a[i] < mi) {
            mi = a[i + 1] - a[i];
            s = i;
        }
    }
    int ans = 0;
    rep(i, a[s] + 1, a[s + 1]) {
        int lower = 1, upper = n / k + 5;
        while(upper - lower > 1) {
            int mid = (lower + upper) / 2;
            int cur = i, idx = s;
            bool res = true;
            rep(j, 0, k - 1) {
                cur += mid;
                if(cur >= a[idx + 2]) {
                    res = false;
                    break;
                }
                cur = max(cur, a[idx + 1] + 1);
                idx++;
            }
            if(i + n - cur < mid) res = false;
            if(res) {
                lower = mid;
            } else {
                upper = mid;
            }
        }
        ans = max(ans, lower);
    }
    cout << ans << '\n';
}
0