結果

問題 No.190 Dry Wet Moist
ユーザー maspymaspy
提出日時 2020-03-05 16:44:05
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 403 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 28,628 KB
最終ジャッジ日時 2023-08-04 04:16:07
合計ジャッジ時間 6,129 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,568 KB
testcase_01 AC 19 ms
8,576 KB
testcase_02 AC 19 ms
8,672 KB
testcase_03 AC 19 ms
8,504 KB
testcase_04 AC 19 ms
8,692 KB
testcase_05 AC 20 ms
8,504 KB
testcase_06 AC 20 ms
8,536 KB
testcase_07 AC 21 ms
8,772 KB
testcase_08 AC 21 ms
8,764 KB
testcase_09 AC 20 ms
8,568 KB
testcase_10 AC 19 ms
8,616 KB
testcase_11 AC 19 ms
8,596 KB
testcase_12 AC 181 ms
17,612 KB
testcase_13 AC 227 ms
18,680 KB
testcase_14 AC 175 ms
16,528 KB
testcase_15 AC 251 ms
19,616 KB
testcase_16 AC 319 ms
22,604 KB
testcase_17 AC 51 ms
10,996 KB
testcase_18 AC 147 ms
15,032 KB
testcase_19 AC 320 ms
22,588 KB
testcase_20 AC 213 ms
18,320 KB
testcase_21 AC 40 ms
9,804 KB
testcase_22 AC 395 ms
28,548 KB
testcase_23 AC 367 ms
28,628 KB
testcase_24 AC 403 ms
28,540 KB
testcase_25 AC 18 ms
8,628 KB
testcase_26 AC 18 ms
8,524 KB
testcase_27 AC 233 ms
21,272 KB
testcase_28 AC 104 ms
13,992 KB
testcase_29 AC 134 ms
15,220 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