結果

問題 No.190 Dry Wet Moist
ユーザー titiatitia
提出日時 2022-06-01 01:50:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 528 ms / 2,000 ms
コード長 808 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 11,824 KB
実行使用メモリ 37,936 KB
最終ジャッジ日時 2023-10-21 00:45:55
合計ジャッジ時間 6,344 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,144 KB
testcase_01 AC 29 ms
10,144 KB
testcase_02 AC 29 ms
10,144 KB
testcase_03 AC 29 ms
10,148 KB
testcase_04 AC 29 ms
10,148 KB
testcase_05 AC 29 ms
10,148 KB
testcase_06 AC 29 ms
10,144 KB
testcase_07 AC 32 ms
10,408 KB
testcase_08 AC 31 ms
10,296 KB
testcase_09 AC 31 ms
10,228 KB
testcase_10 AC 31 ms
10,216 KB
testcase_11 AC 31 ms
10,228 KB
testcase_12 AC 225 ms
20,160 KB
testcase_13 AC 277 ms
22,400 KB
testcase_14 AC 215 ms
20,140 KB
testcase_15 AC 302 ms
22,584 KB
testcase_16 AC 384 ms
27,740 KB
testcase_17 AC 70 ms
12,780 KB
testcase_18 AC 182 ms
18,856 KB
testcase_19 AC 380 ms
27,276 KB
testcase_20 AC 259 ms
20,984 KB
testcase_21 AC 55 ms
11,872 KB
testcase_22 AC 384 ms
34,092 KB
testcase_23 AC 528 ms
37,936 KB
testcase_24 AC 334 ms
32,264 KB
testcase_25 AC 30 ms
10,144 KB
testcase_26 AC 29 ms
10,144 KB
testcase_27 AC 315 ms
26,000 KB
testcase_28 AC 149 ms
18,044 KB
testcase_29 AC 190 ms
19,252 KB
権限があれば一括ダウンロードができます

ソースコード

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