結果

問題 No.190 Dry Wet Moist
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-29 01:40:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 696 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 126,164 KB
最終ジャッジ日時 2024-04-15 01:14:44
合計ジャッジ時間 4,576 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
53,760 KB
testcase_01 AC 48 ms
53,888 KB
testcase_02 AC 44 ms
53,888 KB
testcase_03 AC 45 ms
53,632 KB
testcase_04 AC 44 ms
53,760 KB
testcase_05 AC 44 ms
53,632 KB
testcase_06 AC 45 ms
53,504 KB
testcase_07 WA -
testcase_08 AC 47 ms
54,784 KB
testcase_09 AC 46 ms
54,144 KB
testcase_10 AC 45 ms
54,400 KB
testcase_11 AC 46 ms
54,144 KB
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 218 ms
122,112 KB
testcase_23 AC 239 ms
126,164 KB
testcase_24 AC 225 ms
110,292 KB
testcase_25 AC 44 ms
54,272 KB
testcase_26 AC 43 ms
53,632 KB
testcase_27 WA -
testcase_28 AC 111 ms
86,484 KB
testcase_29 AC 124 ms
91,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
pos = []
neg = []
for a in A:
    if a >= 0:
        pos.append(a)
    else:
        neg.append(a)


dry = 0
p = sorted(pos, reverse=True)
tmp = 0
for n in sorted(neg, reverse=True):
    if p and n + p[-1] < 0:
        dry += 1
        p.pop()
    else:
        tmp += 1
dry += tmp // 2


wet = 0
p = sorted(pos)
for n in sorted(neg):
    if p and n + p[-1] > 0:
        wet += 1
        p.pop()
while len(p) >= 2:
    if p.pop() + p.pop() > 0:
        wet += 1

moist = 0
p = Counter(pos)
n = Counter(neg)
for k, v in n.items():
    vv = p[-k]
    moist += min(v, vv)
moist += p[0] // 2

print(dry, wet, moist)
0