結果

問題 No.190 Dry Wet Moist
ユーザー roaris
提出日時 2019-11-03 13:22:25
言語 PyPy3
(7.0.0)
結果
AC  
実行時間 339 ms
コード長 631 Byte
コンパイル時間 2,008 ms
使用メモリ 121,508 KB
最終ジャッジ日時 2019-11-03 13:22:35

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
00_sample_01.in AC 143 ms
68,612 KB
00_sample_02.in AC 169 ms
68,716 KB
10_small_01.in AC 139 ms
69,764 KB
10_small_02.in AC 141 ms
69,472 KB
10_small_03.in AC 138 ms
69,288 KB
10_small_04.in AC 141 ms
69,512 KB
10_small_05.in AC 142 ms
69,168 KB
20_small_01.in AC 158 ms
70,556 KB
20_small_02.in AC 149 ms
68,908 KB
20_small_03.in AC 179 ms
68,888 KB
20_small_04.in AC 158 ms
68,856 KB
20_small_05.in AC 145 ms
68,856 KB
30_large_01.in AC 248 ms
88,656 KB
30_large_02.in AC 265 ms
92,092 KB
30_large_03.in AC 263 ms
89,452 KB
30_large_04.in AC 296 ms
94,384 KB
30_large_05.in AC 324 ms
104,768 KB
30_large_06.in AC 177 ms
72,104 KB
30_large_07.in AC 225 ms
85,028 KB
30_large_08.in AC 306 ms
103,212 KB
30_large_09.in AC 295 ms
90,376 KB
30_large_10.in AC 175 ms
70,748 KB
40_corner_01.in AC 281 ms
103,252 KB
40_corner_02.in AC 339 ms
121,508 KB
40_corner_03.in AC 278 ms
103,432 KB
40_corner_04.in AC 155 ms
69,204 KB
40_corner_05.in AC 143 ms
69,748 KB
system_test1.txt AC 294 ms
95,596 KB
system_test2.txt AC 213 ms
82,252 KB
system_test3.txt AC 224 ms
84,620 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