結果

問題 No.190 Dry Wet Moist
ユーザー convexineqconvexineq
提出日時 2020-12-17 18:37:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 81,764 KB
実行使用メモリ 114,624 KB
最終ジャッジ日時 2023-10-21 07:02:46
合計ジャッジ時間 4,045 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
63,248 KB
testcase_01 AC 47 ms
63,248 KB
testcase_02 AC 46 ms
63,248 KB
testcase_03 AC 47 ms
63,248 KB
testcase_04 AC 47 ms
63,248 KB
testcase_05 AC 46 ms
63,248 KB
testcase_06 AC 46 ms
63,248 KB
testcase_07 AC 55 ms
67,972 KB
testcase_08 AC 48 ms
65,296 KB
testcase_09 AC 48 ms
65,296 KB
testcase_10 AC 46 ms
63,248 KB
testcase_11 AC 47 ms
65,296 KB
testcase_12 AC 107 ms
94,900 KB
testcase_13 AC 115 ms
100,384 KB
testcase_14 AC 105 ms
94,840 KB
testcase_15 AC 120 ms
103,440 KB
testcase_16 AC 139 ms
110,772 KB
testcase_17 AC 67 ms
76,200 KB
testcase_18 AC 98 ms
90,744 KB
testcase_19 AC 141 ms
111,056 KB
testcase_20 AC 113 ms
97,780 KB
testcase_21 AC 63 ms
74,148 KB
testcase_22 AC 147 ms
111,644 KB
testcase_23 AC 155 ms
111,584 KB
testcase_24 AC 155 ms
114,624 KB
testcase_25 AC 46 ms
63,248 KB
testcase_26 AC 46 ms
63,248 KB
testcase_27 AC 122 ms
98,012 KB
testcase_28 AC 90 ms
85,704 KB
testcase_29 AC 97 ms
89,460 KB
権限があれば一括ダウンロードができます

ソースコード

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