結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,816 KB
testcase_01 AC 10 ms
6,940 KB
testcase_02 AC 11 ms
6,940 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 10 ms
6,944 KB
testcase_07 AC 13 ms
7,040 KB
testcase_08 AC 13 ms
7,040 KB
testcase_09 AC 11 ms
6,944 KB
testcase_10 AC 11 ms
6,944 KB
testcase_11 AC 12 ms
6,944 KB
testcase_12 AC 177 ms
18,640 KB
testcase_13 AC 221 ms
19,768 KB
testcase_14 AC 177 ms
18,244 KB
testcase_15 AC 245 ms
20,240 KB
testcase_16 AC 289 ms
21,988 KB
testcase_17 AC 47 ms
9,728 KB
testcase_18 AC 141 ms
17,912 KB
testcase_19 AC 290 ms
21,908 KB
testcase_20 AC 200 ms
19,208 KB
testcase_21 AC 33 ms
8,060 KB
testcase_22 AC 194 ms
24,184 KB
testcase_23 AC 396 ms
34,132 KB
testcase_24 AC 194 ms
24,056 KB
testcase_25 WA -
testcase_26 AC 11 ms
6,944 KB
testcase_27 AC 247 ms
20,888 KB
testcase_28 AC 119 ms
17,264 KB
testcase_29 AC 151 ms
17,848 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) + max(0,(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) + max(0,(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