結果

問題 No.190 Dry Wet Moist
ユーザー rpy3cpprpy3cpp
提出日時 2015-04-22 11:10:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 31,056 KB
最終ジャッジ日時 2023-09-18 08:08:14
合計ジャッジ時間 3,503 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,804 KB
testcase_01 AC 16 ms
7,820 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 147 ms
31,056 KB
testcase_23 AC 222 ms
30,952 KB
testcase_24 AC 141 ms
30,060 KB
testcase_25 AC 15 ms
7,820 KB
testcase_26 AC 16 ms
7,856 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def find_max_moist(Ap, Am, np, nm, n0):
    c = p = m = 0
    while p < np and m < nm:
        if Ap[p] == Am[m]:
            c += 1
            p += 1
            m += 1
        elif Ap[p] < Am[m]:
            m += 1
        else:
            p += 1
    return c + n0 // 2

def find_max_wet(Ap, Ar, np, nr):
    c = p = r = 0
    while p < np and r < nr:
        if Ap[p] < Ar[r]:
            c += 1
            p += 1
        r += 1
    return c + max((np - p) // 2, 0)

N = int(input())
As = list(map(int, input().split()))
Ap = [-a for a in As if a > 0]
Am = [a for a in As if a < 0]
Ap.sort()
Am.sort()
np = len(Ap)
nm = len(Am)
n0 = 2 * N - np - nm
A0 = [0] * n0
dry = find_max_wet(Am, Ap+A0, nm, np + n0)
wet = find_max_wet(Ap, Am+A0, np, nm + n0)
moist = find_max_moist(Ap, Am, np, nm, n0)
print(dry, wet, moist)
0