結果

問題 No.190 Dry Wet Moist
ユーザー mayoko_mayoko_
提出日時 2015-05-01 15:35:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 1,407 ms
コンパイル使用メモリ 155,904 KB
実行使用メモリ 13,644 KB
最終ジャッジ日時 2023-09-19 04:50:52
合計ジャッジ時間 3,762 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 49 ms
7,768 KB
testcase_13 AC 61 ms
8,604 KB
testcase_14 AC 47 ms
7,672 KB
testcase_15 AC 67 ms
8,856 KB
testcase_16 AC 83 ms
9,844 KB
testcase_17 AC 11 ms
4,688 KB
testcase_18 AC 39 ms
7,088 KB
testcase_19 AC 83 ms
10,028 KB
testcase_20 AC 57 ms
8,596 KB
testcase_21 AC 7 ms
4,376 KB
testcase_22 AC 69 ms
8,304 KB
testcase_23 AC 122 ms
13,644 KB
testcase_24 AC 110 ms
12,368 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 69 ms
9,532 KB
testcase_28 AC 31 ms
6,952 KB
testcase_29 AC 41 ms
7,716 KB
権限があれば一括ダウンロードができます

ソースコード

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.first], m[-el.first]);
        }
    }
    printf("%d %d %d\n", dry, wet, moist);
    return 0;
}
0