結果

問題 No.1594 Three Classes
ユーザー ntudantuda
提出日時 2021-07-22 14:38:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 329 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,908 KB
実行使用メモリ 76,160 KB
最終ジャッジ日時 2024-04-28 00:42:02
合計ジャッジ時間 2,062 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
75,508 KB
testcase_01 AC 41 ms
51,584 KB
testcase_02 AC 40 ms
51,584 KB
testcase_03 AC 48 ms
60,544 KB
testcase_04 AC 40 ms
51,584 KB
testcase_05 AC 67 ms
76,032 KB
testcase_06 AC 45 ms
61,684 KB
testcase_07 AC 46 ms
64,076 KB
testcase_08 AC 67 ms
75,636 KB
testcase_09 AC 65 ms
76,160 KB
testcase_10 AC 65 ms
75,924 KB
testcase_11 AC 70 ms
75,520 KB
testcase_12 AC 64 ms
76,036 KB
testcase_13 AC 42 ms
52,480 KB
testcase_14 AC 58 ms
73,728 KB
testcase_15 AC 51 ms
69,224 KB
testcase_16 AC 48 ms
64,068 KB
testcase_17 AC 44 ms
61,952 KB
testcase_18 AC 38 ms
51,944 KB
testcase_19 AC 38 ms
51,628 KB
testcase_20 AC 45 ms
61,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
N = int(input())
E = list(map(int,input().split()))

if sum(E)%3 > 0:
    print("No")
    sys.exit()

for i in range(3**(N-1)-1):
    S = [0] * 3
    S[0] = E[-1]

    for j in range(N-1):
        S[i%3] += E[j]
        i //= 3
        
    if S[0] == S[1] == S[2]:
        print("Yes")
        sys.exit()

print("No")
0