結果

問題 No.190 Dry Wet Moist
ユーザー pekempeypekempey
提出日時 2015-08-12 15:59:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 1,126 bytes
コンパイル時間 1,587 ms
コンパイル使用メモリ 146,928 KB
実行使用メモリ 5,044 KB
最終ジャッジ日時 2023-09-25 08:28:54
合計ジャッジ時間 3,825 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 36 ms
4,564 KB
testcase_13 AC 44 ms
4,688 KB
testcase_14 AC 35 ms
4,612 KB
testcase_15 AC 49 ms
4,728 KB
testcase_16 AC 60 ms
5,044 KB
testcase_17 AC 9 ms
4,376 KB
testcase_18 AC 28 ms
4,488 KB
testcase_19 AC 59 ms
4,880 KB
testcase_20 AC 42 ms
4,764 KB
testcase_21 AC 7 ms
4,380 KB
testcase_22 AC 70 ms
4,520 KB
testcase_23 AC 74 ms
4,904 KB
testcase_24 AC 77 ms
4,524 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 47 ms
4,748 KB
testcase_28 AC 22 ms
4,464 KB
testcase_29 AC 27 ms
4,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

const int offset = 100000;
int N, a[200000];
int b[offset * 2 + 1];

int main() {
    cin >> N;
    rep (i, 2 * N) {
        cin >> a[i];
        b[a[i] + offset]++;
    }

    sort(a, a + 2 * N);

    int pos = 0, neg = 0, zero = 0;

    // calc pos
    int r = N * 2 - 1;
    rep (i, N * 2) {
        if (i >= r) break;
        if (r > 0 && a[i] + a[r] > 0) {
            pos++;
            r--;
        }
    }

    // calc neg
    int l = 0;
    repr (i, N * 2) {
        if (l >= i) break;
        if (l < N * 2 - 1 && a[l] + a[i] < 0) {
            neg++;
            l++;
        }
    }

    ll z = 0;
    rep2 (i, 1, offset + 1) {
        z += min(b[offset + i], b[offset - i]);
    }

    z += b[offset] / 2;

    z = min<ll>(z, N);

    cout << neg << " " << pos << " " << z << endl;
}
0