結果

問題 No.190 Dry Wet Moist
ユーザー 👑 rin204rin204
提出日時 2022-10-17 22:58:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 112,172 KB
最終ジャッジ日時 2023-09-10 20:55:13
合計ジャッジ時間 4,914 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,212 KB
testcase_01 AC 69 ms
71,012 KB
testcase_02 AC 74 ms
71,116 KB
testcase_03 AC 71 ms
71,296 KB
testcase_04 AC 71 ms
71,404 KB
testcase_05 AC 70 ms
71,264 KB
testcase_06 AC 71 ms
71,216 KB
testcase_07 AC 78 ms
76,660 KB
testcase_08 AC 73 ms
71,296 KB
testcase_09 AC 72 ms
71,328 KB
testcase_10 AC 72 ms
71,184 KB
testcase_11 AC 71 ms
71,452 KB
testcase_12 AC 134 ms
98,224 KB
testcase_13 AC 148 ms
104,080 KB
testcase_14 AC 132 ms
98,228 KB
testcase_15 AC 147 ms
103,444 KB
testcase_16 AC 167 ms
110,412 KB
testcase_17 AC 92 ms
78,164 KB
testcase_18 AC 121 ms
92,832 KB
testcase_19 AC 166 ms
110,244 KB
testcase_20 AC 144 ms
101,972 KB
testcase_21 AC 86 ms
76,716 KB
testcase_22 AC 162 ms
112,172 KB
testcase_23 AC 169 ms
110,216 KB
testcase_24 AC 179 ms
108,712 KB
testcase_25 AC 70 ms
71,324 KB
testcase_26 AC 70 ms
71,236 KB
testcase_27 AC 147 ms
101,300 KB
testcase_28 AC 111 ms
86,520 KB
testcase_29 AC 118 ms
90,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))

def f(A):
    A.sort()
    if A[0] >= 0:
        return 0
    r = 2 * n - 1
    cnt = 0
    for l in range(n):        
        while l < r and A[l] + A[r] >= 0:
            r -= 1
        if l >= r:
            break
        cnt += 1
        r -= 1
    return cnt

dry = f(A)
wet = f([-a for a in A])
cnt = {}
moi = 0
z = 0
A.sort()
for a in A:
    if a < 0:
        cnt[-a] = cnt.get(-a, 0) + 1
    elif a == 0:
        z += 1
    else:
        if cnt.get(a, 0) >= 1:
            cnt[a] -= 1
            moi += 1
moi += z // 2
print(dry, wet, moi)
0