結果

問題 No.190 Dry Wet Moist
ユーザー maspymaspy
提出日時 2020-03-05 16:44:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 29,652 KB
最終ジャッジ日時 2024-04-22 02:37:24
合計ジャッジ時間 5,808 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 31 ms
10,624 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 30 ms
10,624 KB
testcase_05 AC 31 ms
10,752 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 AC 33 ms
11,008 KB
testcase_08 AC 32 ms
10,880 KB
testcase_09 AC 31 ms
10,752 KB
testcase_10 AC 32 ms
10,880 KB
testcase_11 AC 31 ms
10,752 KB
testcase_12 AC 188 ms
18,888 KB
testcase_13 AC 234 ms
20,896 KB
testcase_14 AC 180 ms
18,700 KB
testcase_15 AC 251 ms
21,732 KB
testcase_16 AC 323 ms
25,064 KB
testcase_17 AC 61 ms
12,748 KB
testcase_18 AC 152 ms
17,900 KB
testcase_19 AC 321 ms
24,856 KB
testcase_20 AC 218 ms
20,320 KB
testcase_21 AC 49 ms
12,032 KB
testcase_22 AC 428 ms
29,592 KB
testcase_23 AC 393 ms
29,464 KB
testcase_24 AC 427 ms
29,652 KB
testcase_25 AC 30 ms
10,752 KB
testcase_26 AC 30 ms
10,752 KB
testcase_27 AC 246 ms
23,260 KB
testcase_28 AC 115 ms
16,760 KB
testcase_29 AC 144 ms
17,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque

# %%
N, *A = map(int, read().split())

# %%


def dry(A):
    A = deque(sorted(A))
    ret = 0
    while len(A) >= 2:
        if A[0] + A[-1] < 0:
            ret += 1
            A.popleft()
            A.pop()
        else:
            A.pop()
    return ret


def wet(A):
    return dry([-x for x in A])


def moist(A):
    A = deque(sorted(A))
    ret = 0
    while len(A) >= 2:
        x = A[0] + A[-1]
        if x < 0:
            A.popleft()
        elif x > 0:
            A.pop()
        else:
            A.popleft()
            A.pop()
            ret += 1
    return ret


# %%
print(dry(A), wet(A), moist(A))
0