結果

問題 No.190 Dry Wet Moist
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-11-01 17:48:52
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,403 bytes
コンパイル時間 1,745 ms
コンパイル使用メモリ 164,212 KB
実行使用メモリ 17,864 KB
最終ジャッジ日時 2024-06-12 04:51:45
合計ジャッジ時間 3,812 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 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 AC 54 ms
10,280 KB
testcase_13 AC 69 ms
10,440 KB
testcase_14 AC 52 ms
9,712 KB
testcase_15 AC 76 ms
11,336 KB
testcase_16 AC 92 ms
14,036 KB
testcase_17 AC 13 ms
6,940 KB
testcase_18 AC 43 ms
8,576 KB
testcase_19 AC 93 ms
11,492 KB
testcase_20 AC 62 ms
10,660 KB
testcase_21 AC 8 ms
6,940 KB
testcase_22 AC 73 ms
12,028 KB
testcase_23 AC 135 ms
17,864 KB
testcase_24 AC 103 ms
16,764 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

void main() {
    int N; readf("%d\n", &N);
    auto A = readln.chomp.split(" ").map!(to!int).array;

    int m = 0;
    int z = 0;
    int[int] count;
    foreach (a; A) {
        if (a < 0) count[a] = count.get(a, 0) + 1;
        else if (a == 0) z++;
    }
    m += z / 2;
    foreach (a; A) {
        if (count.get(-a, 0) > 0) {
            count[-a]--;
            m++;
        }
    }

    int calc(int[] W, BinaryHeap!(int[], "a < b") PQ) {
        int ans = 0;
        foreach (i, w; W) {
            if (PQ.empty) {
                break;
            }
            int c = PQ.front; PQ.removeFront;
            if (c > w) {
                ans++;
            } else {
                PQ.insert(c);
            }
        }
        int x = min(W.size - ans, z);
        ans += x + (W.size - ans - x) / 2;
        return ans;
    }

    int w = calc( A.filter!"a > 0".array.sort!"a > b".array, A.filter!"a < 0".map!"-a".array.heapify );
    int d = calc( A.filter!"a < 0".map!"-a".array.sort!"a > b".array, A.filter!"a > 0".array.heapify );
    writefln("%s %s %s", d, w, m);


}
0