結果

問題 No.2890 Chiffon
ユーザー noiminoimi
提出日時 2024-09-13 22:06:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,418 ms / 2,000 ms
コード長 2,179 bytes
コンパイル時間 2,536 ms
コンパイル使用メモリ 206,848 KB
実行使用メモリ 15,076 KB
最終ジャッジ日時 2024-09-13 22:07:06
合計ジャッジ時間 24,986 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1,418 ms
15,076 KB
testcase_23 AC 401 ms
7,620 KB
testcase_24 AC 315 ms
6,780 KB
testcase_25 AC 657 ms
9,932 KB
testcase_26 AC 769 ms
10,412 KB
testcase_27 AC 15 ms
5,376 KB
testcase_28 AC 49 ms
5,376 KB
testcase_29 AC 267 ms
7,080 KB
testcase_30 AC 936 ms
10,992 KB
testcase_31 AC 831 ms
9,948 KB
testcase_32 AC 29 ms
5,376 KB
testcase_33 AC 610 ms
12,644 KB
testcase_34 AC 613 ms
12,860 KB
testcase_35 AC 611 ms
12,736 KB
testcase_36 AC 612 ms
12,612 KB
testcase_37 AC 629 ms
12,696 KB
testcase_38 AC 605 ms
12,736 KB
testcase_39 AC 639 ms
12,772 KB
testcase_40 AC 612 ms
12,728 KB
testcase_41 AC 614 ms
12,864 KB
testcase_42 AC 640 ms
12,740 KB
testcase_43 AC 676 ms
12,736 KB
testcase_44 AC 686 ms
12,736 KB
testcase_45 AC 705 ms
12,608 KB
testcase_46 AC 683 ms
12,732 KB
testcase_47 AC 681 ms
12,868 KB
testcase_48 AC 710 ms
12,684 KB
testcase_49 AC 685 ms
12,632 KB
testcase_50 AC 685 ms
12,868 KB
testcase_51 AC 687 ms
12,696 KB
testcase_52 AC 696 ms
12,864 KB
testcase_53 AC 956 ms
11,060 KB
testcase_54 AC 742 ms
12,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define ov4(a, b, c, d, name, ...) name
#define rep3(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep2(i, a, b) rep3(i, a, b, 1)
#define rep1(i, n) rep2(i, 0, n)
#define rep0(n) rep1(aaaaa, n)
#define rep(...) ov4(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__)
#define per(i, a, b) for(ll i = (a) - 1; i >= (b); i--)
#define fore(e, v) for(auto &&e : v)
#define all(a) begin(a), end(a)
#define si(a) (int)(size(a))
#define lb(v, x) (lower_bound(all(v), x) - begin(v))
#define eb emplace_back

template <typename T, typename S> bool chmin(T &a, const S &b) { return a > b ? a = b, 1 : 0; }
template <typename T, typename S> bool chmax(T &a, const S &b) { return a < b ? a = b, 1 : 0; }

const int INF = 1e9 + 100;
const ll INFL = 3e18 + 100;

#define i128 __int128_t

struct _ {
    _() { cin.tie(0)->sync_with_stdio(0), cout.tie(0); }
} __;

int rnd(int l, int r) {
    static mt19937_64 mt(time(NULL));
    return uniform_int_distribution<int>(l, r - 1)(mt);
}
int main() {
    int n, k;
    cin >> n >> k;
    n *= 2;
    vl a(k);
    fore(e, a) cin >> e, --e;
    vi nxt(n);
    a.eb(a[0] + n);
    rep(i, n) {
        int j = a[lb(a, i)];
        nxt[i] = j - i;
    }
    int ok = 0, ng = n / 2;
    // rep(i, n) { cout << nxt[i] << " "; }
    // cout << endl;
    while(ok + 1 < ng) {
        int mid = ok + ng >> 1;
        int d = mid * 2;
        bool flag = false;
        vi used(n);
        rep((n + k - 1) / k * 5) {
            ll now = rnd(0, n / 2) * 2 + 1;
            if(used[now]++) continue;
            ll st = now;
            int rem = now % n;
            rep(k) {
                int add = max(nxt[rem] + 1, d);
                rem += add;
                if(rem >= n) rem -= n;
                now += add;
            }
            // cout << now << endl;
            if(now <= st + n) {
                flag = true;
                break;
            }
        }
        // cout << d << " " << flag << endl;
        (flag ? ok : ng) = mid;
    }
    cout << ok * 2 << endl;
}
0