結果

問題 No.190 Dry Wet Moist
ユーザー convexineq
提出日時 2020-12-17 18:37:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 115,328 KB
最終ジャッジ日時 2024-09-21 08:11:13
合計ジャッジ時間 3,803 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
*a, = map(int,input().split())

N = 10**5+10
pos = [0]*N
neg = [0]*N
for i in a:
    if i >= 0: pos[i] += 1
    else: neg[-i] += 1

moist = sum(min(i,j) for i,j in zip(pos,neg)) + pos[0]//2

zero = pos[0]
pos = [ai for ai in a if ai > 0]
neg = [-ai for ai in a if ai < 0]
pos.sort()
neg.sort()

def get(a,b):
    L = len(a)
    i = 0
    res = 0
    for bi in b:
        while i < L and a[i] <= bi:
            i += 1
        if i < L and a[i] > bi:
            res += 1
            i += 1
    
    y = L-res
    return res + min(zero,y) + max((y-zero),0)//2
    
print(get(neg,pos),get(pos,neg),moist)
0