結果

問題 No.190 Dry Wet Moist
ユーザー finefine
提出日時 2020-05-22 03:26:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 2,095 ms
コンパイル使用メモリ 172,964 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-04-14 07:45:14
合計ジャッジ時間 5,361 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 61 ms
8,704 KB
testcase_13 AC 78 ms
10,240 KB
testcase_14 AC 57 ms
8,704 KB
testcase_15 AC 82 ms
10,752 KB
testcase_16 AC 105 ms
13,056 KB
testcase_17 AC 14 ms
6,944 KB
testcase_18 AC 48 ms
7,808 KB
testcase_19 AC 105 ms
12,800 KB
testcase_20 AC 72 ms
9,728 KB
testcase_21 AC 9 ms
6,940 KB
testcase_22 AC 129 ms
13,440 KB
testcase_23 AC 108 ms
13,440 KB
testcase_24 AC 149 ms
13,440 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 74 ms
9,728 KB
testcase_28 AC 32 ms
6,940 KB
testcase_29 AC 43 ms
7,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr char newl = '\n';

int calc(const vector<int>& v, bool is_moist) {
    multiset<int> s(v.begin(), v.end());
    int res = 0;
    while (!s.empty()) {
        auto it = s.begin();
        int x = *it;
        s.erase(it);

        it = (is_moist ? s.find(-x) : s.upper_bound(-x));
        if (it == s.end()) continue;
        ++res;
        s.erase(it);
    }
    return res;
}

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

    int n;
    cin >> n;
    n <<= 1;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int wet = calc(a, false);
    int moist = calc(a, true);

    for (int i = 0; i < n; i++) {
        a[i] = -a[i];
    }
    reverse(a.begin(), a.end());
    int dry = calc(a, false);
    
    cout << dry << " " << wet << " " << moist << newl;

    return 0;
}
0