結果

問題 No.190 Dry Wet Moist
ユーザー roarisroaris
提出日時 2019-11-03 13:22:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 631 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 110,048 KB
最終ジャッジ日時 2023-10-13 01:46:44
合計ジャッジ時間 6,209 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,624 KB
testcase_01 AC 94 ms
71,676 KB
testcase_02 AC 91 ms
71,796 KB
testcase_03 AC 92 ms
71,572 KB
testcase_04 AC 93 ms
71,772 KB
testcase_05 AC 93 ms
71,584 KB
testcase_06 AC 94 ms
71,756 KB
testcase_07 AC 116 ms
77,732 KB
testcase_08 AC 105 ms
76,496 KB
testcase_09 AC 103 ms
76,468 KB
testcase_10 AC 101 ms
76,512 KB
testcase_11 AC 105 ms
76,548 KB
testcase_12 AC 184 ms
93,300 KB
testcase_13 AC 200 ms
98,692 KB
testcase_14 AC 179 ms
93,460 KB
testcase_15 AC 207 ms
101,820 KB
testcase_16 AC 238 ms
108,908 KB
testcase_17 AC 130 ms
79,484 KB
testcase_18 AC 172 ms
89,484 KB
testcase_19 AC 233 ms
108,748 KB
testcase_20 AC 193 ms
96,440 KB
testcase_21 AC 127 ms
79,568 KB
testcase_22 AC 205 ms
109,972 KB
testcase_23 AC 267 ms
109,628 KB
testcase_24 AC 206 ms
110,048 KB
testcase_25 AC 90 ms
71,724 KB
testcase_26 AC 94 ms
71,620 KB
testcase_27 AC 218 ms
96,288 KB
testcase_28 AC 165 ms
86,972 KB
testcase_29 AC 173 ms
88,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort()
wet = 0
prev_idx = 2*N

for i in range(2*N):
    idx = bisect_left(A, -A[i])-1
    idx = min(idx, prev_idx-1)
    
    if i < idx:
        wet += 1
        prev_idx = idx
    else:
        break

dry = 0
prev_idx = -1

for i in range(2*N-1, -1, -1):
    idx = bisect_right(A, -A[i])
    idx = max(idx, prev_idx+1)
    
    if idx < i:
        dry += 1
        prev_idx = idx
    else:
        break

moist = 0
d = Counter(A)

for k, v in d.items():
    moist += min(d[k], d[-k])

moist //= 2

print(wet, dry, moist)
0