結果
問題 | No.190 Dry Wet Moist |
ユーザー | tktk_snsn |
提出日時 | 2020-12-29 01:53:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 230 ms / 2,000 ms |
コード長 | 930 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 82,780 KB |
実行使用メモリ | 127,172 KB |
最終ジャッジ日時 | 2024-04-15 01:26:58 |
合計ジャッジ時間 | 4,510 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
54,516 KB |
testcase_01 | AC | 42 ms
54,848 KB |
testcase_02 | AC | 42 ms
53,968 KB |
testcase_03 | AC | 42 ms
55,816 KB |
testcase_04 | AC | 43 ms
55,116 KB |
testcase_05 | AC | 43 ms
54,804 KB |
testcase_06 | AC | 41 ms
55,392 KB |
testcase_07 | AC | 53 ms
64,604 KB |
testcase_08 | AC | 44 ms
55,904 KB |
testcase_09 | AC | 44 ms
55,432 KB |
testcase_10 | AC | 42 ms
54,700 KB |
testcase_11 | AC | 45 ms
55,640 KB |
testcase_12 | AC | 128 ms
97,516 KB |
testcase_13 | AC | 144 ms
103,588 KB |
testcase_14 | AC | 125 ms
96,984 KB |
testcase_15 | AC | 158 ms
99,272 KB |
testcase_16 | AC | 199 ms
108,684 KB |
testcase_17 | AC | 79 ms
78,432 KB |
testcase_18 | AC | 113 ms
91,912 KB |
testcase_19 | AC | 186 ms
107,572 KB |
testcase_20 | AC | 136 ms
101,096 KB |
testcase_21 | AC | 68 ms
73,596 KB |
testcase_22 | AC | 211 ms
121,572 KB |
testcase_23 | AC | 230 ms
127,172 KB |
testcase_24 | AC | 205 ms
109,972 KB |
testcase_25 | AC | 41 ms
55,044 KB |
testcase_26 | AC | 42 ms
54,368 KB |
testcase_27 | AC | 165 ms
103,140 KB |
testcase_28 | AC | 104 ms
85,464 KB |
testcase_29 | AC | 118 ms
90,804 KB |
ソースコード
from collections import Counter N = int(input()) A = list(map(int, input().split())) p = [] z = [] n = [] for a in A: if a > 0: p.append(a) elif a == 0: z.append(a) else: n.append(a) # dry dry = 0 pos = sorted(p) neg = sorted(n, reverse=True) zero = z[:] while pos and neg: if pos[-1] + neg[-1] >= 0: pos.pop() else: pos.pop() neg.pop() dry += 1 while neg and zero: dry += 1 neg.pop() zero.pop() dry += len(neg) // 2 # wet wet = 0 pos = sorted(p) neg = sorted(n, reverse=True) zero = z[:] while pos and neg: if pos[-1] + neg[-1] <= 0: neg.pop() else: pos.pop() neg.pop() wet += 1 while pos and zero: wet += 1 pos.pop() zero.pop() wet += len(pos) // 2 # moist moist = len(z) // 2 cp = Counter(p) cn = Counter(n) for k, v in cp.items(): moist += min(v, cn[-k]) print(dry, wet, moist)