結果

問題 No.2890 Chiffon
ユーザー 👑 seekworserseekworser
提出日時 2024-07-02 18:43:16
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 1,041 bytes
コンパイル時間 3,201 ms
コンパイル使用メモリ 248,672 KB
実行使用メモリ 11,224 KB
最終ジャッジ日時 2024-07-06 11:12:53
合計ジャッジ時間 6,266 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 165 ms
11,224 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 3 ms
6,940 KB
testcase_25 AC 3 ms
6,944 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 3 ms
6,944 KB
testcase_30 AC 3 ms
6,940 KB
testcase_31 AC 3 ms
6,944 KB
testcase_32 AC 3 ms
6,940 KB
testcase_33 AC 69 ms
6,940 KB
testcase_34 AC 68 ms
6,940 KB
testcase_35 AC 68 ms
6,940 KB
testcase_36 AC 67 ms
6,944 KB
testcase_37 AC 68 ms
6,940 KB
testcase_38 AC 67 ms
6,940 KB
testcase_39 AC 68 ms
6,940 KB
testcase_40 AC 68 ms
6,944 KB
testcase_41 AC 68 ms
6,948 KB
testcase_42 AC 69 ms
6,940 KB
testcase_43 AC 69 ms
6,944 KB
testcase_44 AC 69 ms
6,944 KB
testcase_45 AC 69 ms
6,940 KB
testcase_46 AC 68 ms
6,940 KB
testcase_47 AC 68 ms
6,940 KB
testcase_48 AC 68 ms
6,940 KB
testcase_49 AC 67 ms
6,940 KB
testcase_50 AC 68 ms
6,940 KB
testcase_51 AC 68 ms
6,944 KB
testcase_52 AC 69 ms
6,940 KB
testcase_53 AC 7 ms
6,940 KB
testcase_54 AC 47 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll n,k; cin >> n >> k;
    vector<ll> a(k+1);
    for (size_t i=0; i<k; i++) cin >> a[i];
    a[k] = a[0] + 2*n;

    vector<ll> an(k+1);
    for (size_t i=0; i<k; i++) {
        if (a[i+1] - a[i] <= (2*n) / k + 1) {
            for (size_t j=0; j<k; j++) an[j] = (a[(i+j) % k] - a[i] + 2*n) % (2*n);
            an[k] = 2*n;
            break;
        }
    }
    ll ans = 0;
    for (ll s = an[0]+1; s < an[1]; s += 2) {
        ll ok = 0, ng = n;
        auto is_ok = [&] (ll mid) -> bool {
            ll x = 2 * mid;
            ll t = s;
            for (size_t i=0; i<k-1; i++) {
                if (t + x >= an[i+2]) return false;
                t = max(t+x, an[i+1]+1);
            }
            return t+x <= s+2*n;
        };
        while (ng - ok > 1) {
            ll mid = (ok + ng) / 2;
            if (is_ok(mid)) ok = mid;
            else ng = mid;
        }
        ans = max(ans, 2*ok);
    }
    cout << ans << endl;
    return 0;
}
0