結果

問題 No.190 Dry Wet Moist
ユーザー mayoko_mayoko_
提出日時 2015-05-01 15:32:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,203 bytes
コンパイル時間 1,615 ms
コンパイル使用メモリ 155,884 KB
実行使用メモリ 13,608 KB
最終ジャッジ日時 2023-09-19 04:50:44
合計ジャッジ時間 4,852 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 69 ms
8,304 KB
testcase_23 AC 102 ms
13,608 KB
testcase_24 AC 95 ms
8,312 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;

const int MAXN = 211111;
int A[MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    N <<= 1;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A, A+N);
    int dry, wet, moist;
    {
        dry = 0;
        int s = 0, t = N-1;
        while (s < t) {
            while (s < t && A[s]+A[t] >= 0) t--;
            if (s >= t) break;
            dry++;
            s++;
            t--;
        }
    }
    {
        wet = 0;
        int s = 0, t = N-1;
        while (s < t) {
            while (s < t && A[s]+A[t] <= 0) s++;
            if (s >= t) break;
            wet++;
            t--;
            s++;
        }
    }
    {
        moist = 0;
        map<int, int> m;
        for (int i = 0; i < N; i++) m[A[i]]++;
        moist += m[0]/2;
        for (auto el : m) {
            if (el.first >= 0) break;
            moist += min(m[el.second], m[-el.second]);
        }
    }
    printf("%d %d %d\n", dry, wet, moist);
    return 0;
}
0