提出 #65260227


ソースコード 拡げる

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main() {
    int N;
    long long D;
    cin >> N >> D;
    vector<long long> arr(N);
    for (int i = 0; i < N; ++i) {
        cin >> arr[i];
    }

    map<long long, int> cnt;
    for (auto a : arr) {
        cnt[a]++;
    }

    int del = 0;

    for (auto [x, freq] : cnt) {
        if (cnt[x] > 0 && cnt.count(x + D)) {
            int conflict = min(cnt[x], cnt[x + D]);
            del += conflict;
            cnt[x + D] -= conflict;
        }
    }

    cout << del << endl;
    return 0;
}

提出情報

提出日時
問題 D - Forbidden Difference
ユーザ sivasaran2003
言語 C++ 17 (gcc 12.2)
得点 0
コード長 634 Byte
結果 WA
実行時間 150 ms
メモリ 15992 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 425
結果
AC × 3
AC × 34
WA × 6
セット名 テストケース
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt
ケース名 結果 実行時間 メモリ
00_sample_01.txt AC 1 ms 3424 KiB
00_sample_02.txt AC 1 ms 3448 KiB
00_sample_03.txt AC 1 ms 3460 KiB
01_random_01.txt AC 22 ms 4684 KiB
01_random_02.txt AC 2 ms 3568 KiB
01_random_03.txt AC 22 ms 4716 KiB
01_random_04.txt AC 8 ms 3624 KiB
01_random_05.txt AC 22 ms 4740 KiB
01_random_06.txt AC 19 ms 4420 KiB
01_random_07.txt WA 22 ms 4636 KiB
01_random_08.txt AC 13 ms 3848 KiB
01_random_09.txt AC 27 ms 4632 KiB
01_random_10.txt AC 25 ms 4480 KiB
01_random_11.txt AC 28 ms 4704 KiB
01_random_12.txt AC 21 ms 4424 KiB
01_random_13.txt AC 28 ms 4688 KiB
01_random_14.txt AC 12 ms 3844 KiB
01_random_15.txt WA 28 ms 4824 KiB
01_random_16.txt AC 8 ms 3584 KiB
01_random_17.txt AC 49 ms 5232 KiB
01_random_18.txt AC 39 ms 4896 KiB
01_random_19.txt AC 49 ms 5168 KiB
01_random_20.txt AC 31 ms 4824 KiB
01_random_21.txt AC 49 ms 5228 KiB
01_random_22.txt AC 46 ms 5224 KiB
01_random_23.txt WA 49 ms 5172 KiB
01_random_24.txt AC 29 ms 4644 KiB
01_random_25.txt AC 123 ms 15992 KiB
01_random_26.txt AC 19 ms 5740 KiB
01_random_27.txt AC 125 ms 15964 KiB
01_random_28.txt AC 21 ms 6020 KiB
01_random_29.txt AC 112 ms 15988 KiB
01_random_30.txt AC 104 ms 14724 KiB
01_random_31.txt WA 150 ms 15952 KiB
01_random_32.txt AC 29 ms 6808 KiB
02_handmade_01.txt AC 35 ms 4684 KiB
02_handmade_02.txt WA 36 ms 4840 KiB
02_handmade_03.txt WA 1 ms 3432 KiB
02_handmade_04.txt AC 1 ms 3480 KiB
02_handmade_05.txt AC 1 ms 3648 KiB