結果

問題 No.190 Dry Wet Moist
ユーザー maine_honzukimaine_honzuki
提出日時 2020-11-23 01:43:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 3,325 ms
コンパイル使用メモリ 203,812 KB
実行使用メモリ 7,820 KB
最終ジャッジ日時 2023-09-30 23:13:02
合計ジャッジ時間 5,502 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,192 KB
testcase_01 AC 3 ms
7,376 KB
testcase_02 AC 3 ms
7,296 KB
testcase_03 AC 4 ms
7,248 KB
testcase_04 AC 4 ms
7,304 KB
testcase_05 AC 3 ms
7,408 KB
testcase_06 AC 4 ms
7,276 KB
testcase_07 AC 4 ms
7,200 KB
testcase_08 AC 4 ms
7,308 KB
testcase_09 AC 4 ms
7,252 KB
testcase_10 AC 4 ms
7,320 KB
testcase_11 AC 4 ms
7,304 KB
testcase_12 AC 37 ms
7,580 KB
testcase_13 AC 45 ms
7,396 KB
testcase_14 AC 36 ms
7,364 KB
testcase_15 AC 49 ms
7,552 KB
testcase_16 AC 62 ms
7,784 KB
testcase_17 AC 10 ms
7,344 KB
testcase_18 AC 31 ms
7,196 KB
testcase_19 AC 62 ms
7,820 KB
testcase_20 AC 43 ms
7,460 KB
testcase_21 AC 8 ms
7,316 KB
testcase_22 AC 72 ms
7,712 KB
testcase_23 AC 77 ms
7,624 KB
testcase_24 AC 78 ms
7,636 KB
testcase_25 AC 3 ms
7,252 KB
testcase_26 AC 3 ms
7,344 KB
testcase_27 AC 49 ms
7,548 KB
testcase_28 AC 24 ms
7,296 KB
testcase_29 AC 29 ms
7,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int maine(vector<int>& A) {
    int book = 0;
    int l = 0, r = A.size() - 1;
    while (l < r) {
        if (A[l] + A[r] < 0) {
            book++;
            l++;
            r--;
        } else
            r--;
    }
    return book;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N * 2);
    for (int i = 0; i < N * 2; i++) {
        cin >> A[i];
    }

    int dry, wet, moist;
    sort(A.begin(), A.end());
    dry = maine(A);
    reverse(A.begin(), A.end());
    for (auto& x : A)
        x *= -1;
    wet = maine(A);

    int cnt[1000010] = {};
    for (auto& x : A) {
        cnt[x + 100000]++;
    }

    moist = 0;
    for (int i = 1; i <= 100000; i++) {
        moist += min(cnt[100000 + i], cnt[100000 - i]);
    }
    moist += cnt[100000] / 2;

    cout << dry << " " << wet << " " << moist << endl;
}
0