結果

問題 No.190 Dry Wet Moist
ユーザー roaris
提出日時 2019-11-03 13:27:19
言語 PyPy3
(7.0.0)
結果
AC  
実行時間 361 ms
コード長 667 Byte
コンパイル時間 264 ms
使用メモリ 122,556 KB
最終ジャッジ日時 2019-11-03 13:27:28

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
00_sample_01.in AC 148 ms
69,696 KB
00_sample_02.in AC 144 ms
69,496 KB
10_small_01.in AC 144 ms
68,628 KB
10_small_02.in AC 165 ms
69,148 KB
10_small_03.in AC 163 ms
69,832 KB
10_small_04.in AC 144 ms
68,640 KB
10_small_05.in AC 144 ms
68,916 KB
20_small_01.in AC 160 ms
69,368 KB
20_small_02.in AC 155 ms
69,248 KB
20_small_03.in AC 147 ms
68,900 KB
20_small_04.in AC 161 ms
70,028 KB
20_small_05.in AC 164 ms
69,004 KB
30_large_01.in AC 285 ms
89,912 KB
30_large_02.in AC 275 ms
92,096 KB
30_large_03.in AC 250 ms
88,400 KB
30_large_04.in AC 284 ms
95,524 KB
30_large_05.in AC 361 ms
105,460 KB
30_large_06.in AC 194 ms
72,628 KB
30_large_07.in AC 245 ms
85,032 KB
30_large_08.in AC 320 ms
104,228 KB
30_large_09.in AC 270 ms
90,504 KB
30_large_10.in AC 215 ms
70,664 KB
40_corner_01.in AC 294 ms
104,436 KB
40_corner_02.in AC 348 ms
122,556 KB
40_corner_03.in AC 293 ms
103,500 KB
40_corner_04.in AC 145 ms
69,340 KB
40_corner_05.in AC 150 ms
69,352 KB
system_test1.txt AC 311 ms
94,784 KB
system_test2.txt AC 226 ms
81,688 KB
system_test3.txt AC 243 ms
84,044 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():
    if k != 0:
        moist += min(d[k], d[-k])

moist //= 2
moist += d[0]//2

print(wet, dry, moist)
0