結果

問題 No.190 Dry Wet Moist
ユーザー nebukuro09nebukuro09
提出日時 2016-09-29 11:26:46
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 1,012 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 34,188 KB
最終ジャッジ日時 2024-05-01 07:39:56
合計ジャッジ時間 5,436 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 < N 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)

posi_n = 0
p1 = 0
p2 = len(posi)-1
while p1 < N 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)

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