結果

問題 No.190 Dry Wet Moist
ユーザー titia
提出日時 2022-06-01 01:50:45
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 469 ms / 2,000 ms
コード長 808 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 38,420 KB
最終ジャッジ日時 2024-09-21 01:26:35
合計ジャッジ時間 5,491 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

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

MINUS=[]
ZERO=0
PLUS=[]

for a in A:
    if a<0:
        MINUS.append(-a)
    elif a==0:
        ZERO+=1
    else:
        PLUS.append(a)

CM=Counter(MINUS)
CP=Counter(PLUS)

mans=0

for cp in CP:
    mans+=min(CP[cp],CM[cp])

mans+=ZERO//2

wans=0

M2=MINUS+[0]*ZERO
P2=PLUS[:]

M2.sort()
P2.sort()

ind=0
for i in range(len(M2)):
    while ind<len(P2) and P2[ind]<=M2[i]:
        ind+=1
    if ind<len(P2):
        wans+=1
        ind+=1

wans+=(len(P2)-wans)//2

#print(wans)

dans=0

M2=MINUS[:]
P2=PLUS+[0]*ZERO

M2.sort()
P2.sort()

ind=0
for i in range(len(P2)):
    while ind<len(M2) and M2[ind]<=P2[i]:
        ind+=1
    if ind<len(M2):
        dans+=1
        ind+=1

dans+=(len(M2)-dans)//2

print(dans,wans,mans)
0