結果

問題 No.1594 Three Classes
ユーザー ayaoniayaoni
提出日時 2021-07-09 21:24:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 156,532 KB
最終ジャッジ日時 2024-04-27 23:51:22
合計ジャッジ時間 4,536 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 290 ms
156,408 KB
testcase_01 AC 36 ms
52,480 KB
testcase_02 AC 33 ms
52,352 KB
testcase_03 AC 193 ms
156,344 KB
testcase_04 AC 32 ms
53,560 KB
testcase_05 AC 281 ms
156,152 KB
testcase_06 AC 193 ms
156,272 KB
testcase_07 AC 187 ms
156,404 KB
testcase_08 AC 284 ms
156,532 KB
testcase_09 AC 279 ms
156,152 KB
testcase_10 AC 282 ms
156,404 KB
testcase_11 AC 271 ms
156,280 KB
testcase_12 AC 279 ms
156,408 KB
testcase_13 AC 33 ms
53,076 KB
testcase_14 AC 195 ms
156,400 KB
testcase_15 AC 202 ms
156,276 KB
testcase_16 AC 87 ms
100,100 KB
testcase_17 AC 186 ms
156,152 KB
testcase_18 AC 34 ms
52,480 KB
testcase_19 AC 33 ms
52,096 KB
testcase_20 AC 46 ms
64,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import product
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()
E = LI()
s = sum(E)

if s % 3 != 0:
    print('No')
    exit()

for A in list(product([0,1,2],repeat=N)):
    x,y,z = 0,0,0
    for i in range(N):
        if A[i] == 0:
            x += E[i]
        elif A[i] == 1:
            y += E[i]
        else:
            z += E[i]
    if x == y == z:
        print('Yes')
        break
else:
    print('No')
0