結果

問題 No.2930 Larger Mex
ユーザー loop0919loop0919
提出日時 2024-09-13 16:47:32
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,426 bytes
コンパイル時間 944 ms
コンパイル使用メモリ 99,984 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2024-10-12 06:39:39
合計ジャッジ時間 5,208 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,248 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
5,248 KB
testcase_05 WA -
testcase_06 AC 2 ms
5,248 KB
testcase_07 AC 2 ms
5,248 KB
testcase_08 AC 29 ms
5,248 KB
testcase_09 AC 27 ms
5,248 KB
testcase_10 AC 31 ms
5,248 KB
testcase_11 AC 24 ms
5,248 KB
testcase_12 AC 33 ms
5,248 KB
testcase_13 AC 33 ms
5,248 KB
testcase_14 AC 33 ms
5,504 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 34 ms
5,632 KB
testcase_26 AC 26 ms
5,248 KB
testcase_27 AC 21 ms
5,248 KB
testcase_28 AC 24 ms
5,248 KB
testcase_29 AC 25 ms
5,248 KB
testcase_30 AC 29 ms
5,248 KB
testcase_31 AC 25 ms
5,248 KB
testcase_32 AC 31 ms
5,248 KB
testcase_33 AC 31 ms
5,248 KB
testcase_34 WA -
testcase_35 AC 20 ms
5,248 KB
testcase_36 WA -
testcase_37 AC 31 ms
5,248 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 25 ms
5,248 KB
testcase_43 AC 25 ms
5,248 KB
testcase_44 AC 25 ms
5,248 KB
testcase_45 AC 25 ms
5,248 KB
testcase_46 AC 33 ms
5,248 KB
testcase_47 AC 33 ms
5,248 KB
testcase_48 AC 22 ms
5,248 KB
testcase_49 AC 35 ms
5,248 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 34 ms
5,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Generated by ChatGPT o1-preview (TLEを指摘ver)
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int &x : A) cin >> x;

    if (M == 0) {
        // 全ての部分列が条件を満たす
        for (int k = 1; k <= N; ++k) {
            cout << N - k + 1 << "\n";
        }
        return 0;
    }

    vector<int> ans(N + 1, 0);
    vector<int> count(M, 0);
    int total = 0;
    int left = 0;

    // 各長さの部分列の数をカウントするためのマップ
    map<int, int> length_count;

    for (int right = 0; right < N; ++right) {
        if (A[right] < M) {
            if (count[A[right]] == 0) total++;
            count[A[right]]++;
        }
        while (total == M) {
            // 部分列の長さを計算
            int len = right - left + 1;
            if (len <= N) {
                length_count[len]++;
            }
            if (A[left] < M) {
                count[A[left]]--;
                if (count[A[left]] == 0) total--;
            }
            left++;
        }
    }

    // 累積的にカウントを集計
    for (auto &[len, cnt] : length_count) {
        ans[len] += cnt;
    }
    for (int k = 1; k <= N; ++k) {
        ans[k] += ans[k - 1];
        cout << ans[k] << "\n";
    }

    return 0;
}
0