結果

問題 No.190 Dry Wet Moist
ユーザー rlangevinrlangevin
提出日時 2023-07-18 12:05:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 1,290 ms
コンパイル使用メモリ 81,632 KB
実行使用メモリ 108,148 KB
最終ジャッジ日時 2023-10-18 15:15:51
合計ジャッジ時間 4,470 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,512 KB
testcase_01 AC 42 ms
55,512 KB
testcase_02 AC 41 ms
55,512 KB
testcase_03 AC 43 ms
55,512 KB
testcase_04 AC 42 ms
55,512 KB
testcase_05 AC 43 ms
55,512 KB
testcase_06 AC 43 ms
55,512 KB
testcase_07 AC 52 ms
64,248 KB
testcase_08 AC 47 ms
60,984 KB
testcase_09 AC 46 ms
60,984 KB
testcase_10 AC 46 ms
60,984 KB
testcase_11 AC 46 ms
60,984 KB
testcase_12 AC 138 ms
94,004 KB
testcase_13 AC 149 ms
100,288 KB
testcase_14 AC 136 ms
93,688 KB
testcase_15 AC 162 ms
102,872 KB
testcase_16 AC 187 ms
108,148 KB
testcase_17 AC 86 ms
78,036 KB
testcase_18 AC 121 ms
88,800 KB
testcase_19 AC 184 ms
108,112 KB
testcase_20 AC 144 ms
97,684 KB
testcase_21 AC 81 ms
76,524 KB
testcase_22 AC 157 ms
108,020 KB
testcase_23 AC 167 ms
107,780 KB
testcase_24 AC 166 ms
107,820 KB
testcase_25 AC 41 ms
55,512 KB
testcase_26 AC 42 ms
55,512 KB
testcase_27 AC 142 ms
98,180 KB
testcase_28 AC 99 ms
83,876 KB
testcase_29 AC 107 ms
85,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

N = int(input())
A = list(map(int, input().split()))
A.sort()

D = deque(A)
ans = []

cnt = 0
while len(D) >= 2:
    if abs(D[0]) <= abs(D[-1]) and D[-1] >= 0:
        D.pop()
    else:
        if D[0] + D[-1] >= 0:
            break
        D.popleft()
        D.pop()
        cnt += 1
ans.append(cnt)

D = deque(A)
cnt = 0
while len(D) >= 2:
    if abs(D[0]) >= abs(D[-1]) and D[0] <= 0:
        D.popleft()
    else:
        if D[0] + D[-1] <= 0:
            break
        D.popleft()
        D.pop()
        cnt += 1
ans.append(cnt)


D = deque(A)
cnt = 0
while len(D) >= 2:
    if abs(D[0]) < abs(D[-1]):
        D.pop()
    elif abs(D[0]) > abs(D[-1]):
        D.popleft()
    else:
        if D[0] + D[-1] != 0:
            break
        D.popleft()
        D.pop()
        cnt += 1
ans.append(cnt)

print(*ans)
0