結果

問題 No.190 Dry Wet Moist
ユーザー nebukuro09nebukuro09
提出日時 2016-09-29 11:48:21
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 1,114 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 7,068 KB
実行使用メモリ 34,188 KB
最終ジャッジ日時 2024-05-01 07:40:50
合計ジャッジ時間 4,740 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,816 KB
testcase_01 AC 11 ms
6,940 KB
testcase_02 AC 11 ms
6,944 KB
testcase_03 AC 11 ms
6,940 KB
testcase_04 AC 11 ms
6,944 KB
testcase_05 AC 11 ms
6,944 KB
testcase_06 AC 11 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 13 ms
6,940 KB
testcase_09 AC 12 ms
6,940 KB
testcase_10 AC 12 ms
6,940 KB
testcase_11 AC 11 ms
6,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 199 ms
24,184 KB
testcase_23 AC 400 ms
34,188 KB
testcase_24 AC 192 ms
24,056 KB
testcase_25 WA -
testcase_26 AC 11 ms
6,940 KB
testcase_27 AC 253 ms
20,948 KB
testcase_28 AC 120 ms
17,268 KB
testcase_29 AC 150 ms
17,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

N = input()
A = sorted(map(int, raw_input().split()))
nega = []
zero = []
posi = []
for a in A:
    if a < 0:
        nega.append(a)
    elif a == 0:
        zero.append(a)
    else:
        posi.append(a)

if len(nega) == 0:
    print 0, len(zero)+max(0, len(posi)-len(zero))/2, len(zero)/2
    exit()
if len(posi) == 0:
    print len(zero)+max(0, len(nega)-len(zero))/2, 0, len(zero)/2
    exit()

nega_n = 0
p1 = 0
p2 = len(posi)-1
while p1 < len(nega) and p2 >= 0:
    if nega[p1]+posi[p2] < 0:
        p1 += 1
        p2 -= 1
        nega_n += 1
    else:
        p2 -= 1
nega_n += min(len(zero), len(nega)-nega_n-len(zero)) + (len(nega)-nega_n-len(zero))/2

posi_n = 0
p1 = 0
p2 = len(posi)-1
while p1 < len(nega) and p2 >= 0:
    if nega[p1]+posi[p2] > 0:
        p1 += 1
        p2 -= 1
        posi_n += 1
    else:
        p1 += 1
posi_n += min(len(zero), len(posi)-posi_n-len(zero)) + (len(posi)-posi_n-len(zero))/2

nega = map(abs, nega)
c1 = Counter(nega)
c2 = Counter(posi)
moist = len(zero)/2
for k in c1:
    moist += min(c1[k], c2[k])

print nega_n, posi_n, moist
0