結果

問題 No.190 Dry Wet Moist
ユーザー しらっ亭しらっ亭
提出日時 2015-07-16 00:54:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 31,160 KB
最終ジャッジ日時 2023-09-22 16:37:07
合計ジャッジ時間 4,852 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,856 KB
testcase_01 AC 16 ms
7,768 KB
testcase_02 AC 16 ms
7,840 KB
testcase_03 AC 16 ms
7,836 KB
testcase_04 AC 16 ms
7,784 KB
testcase_05 AC 15 ms
7,844 KB
testcase_06 AC 16 ms
7,772 KB
testcase_07 AC 17 ms
8,232 KB
testcase_08 AC 17 ms
8,320 KB
testcase_09 AC 16 ms
7,788 KB
testcase_10 AC 16 ms
7,772 KB
testcase_11 AC 16 ms
8,356 KB
testcase_12 AC 118 ms
17,704 KB
testcase_13 AC 144 ms
19,628 KB
testcase_14 AC 112 ms
17,128 KB
testcase_15 AC 157 ms
20,804 KB
testcase_16 AC 199 ms
24,460 KB
testcase_17 AC 37 ms
9,944 KB
testcase_18 AC 97 ms
15,304 KB
testcase_19 AC 193 ms
24,116 KB
testcase_20 AC 137 ms
18,848 KB
testcase_21 AC 29 ms
9,364 KB
testcase_22 AC 144 ms
30,964 KB
testcase_23 AC 214 ms
31,160 KB
testcase_24 AC 149 ms
29,992 KB
testcase_25 AC 16 ms
7,768 KB
testcase_26 AC 16 ms
7,828 KB
testcase_27 AC 144 ms
22,944 KB
testcase_28 AC 72 ms
14,696 KB
testcase_29 AC 86 ms
15,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(N, A):
    A.sort()

    i = 0
    j = len(A) - 1
    d = 0
    while i < j and A[i] <= 0:
        if -A[i] > A[j]:
            d += 1
            i += 1
            j -= 1
        else:
            j -= 1

    i = 0
    j = len(A) - 1
    w = 0
    while i < j and 0 <= A[j]:
        if -A[i] < A[j]:
            w += 1
            i += 1
            j -= 1
        else:
            i += 1

    i = 0
    j = len(A) - 1
    m = 0
    while i < j and A[i] <= 0 <= A[j]:
        s = A[j] + A[i]
        if s == 0:
            m += 1
            i += 1
            j -= 1
        elif s < 0:
            i += 1
        elif s > 0:
            j -= 1

    print(d, w, m)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    solve(N, A)


if __name__ == '__main__':
    main()
0