結果

問題 No.1594 Three Classes
ユーザー ayaoniayaoni
提出日時 2021-07-09 21:24:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 158,480 KB
最終ジャッジ日時 2023-08-10 06:33:38
合計ジャッジ時間 5,748 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 327 ms
158,080 KB
testcase_01 AC 71 ms
71,624 KB
testcase_02 AC 69 ms
71,580 KB
testcase_03 AC 220 ms
158,312 KB
testcase_04 AC 69 ms
71,324 KB
testcase_05 AC 320 ms
158,128 KB
testcase_06 AC 213 ms
158,004 KB
testcase_07 AC 219 ms
158,156 KB
testcase_08 AC 320 ms
158,408 KB
testcase_09 AC 318 ms
158,224 KB
testcase_10 AC 326 ms
158,220 KB
testcase_11 AC 322 ms
158,212 KB
testcase_12 AC 321 ms
158,292 KB
testcase_13 AC 69 ms
71,576 KB
testcase_14 AC 226 ms
158,480 KB
testcase_15 AC 224 ms
158,284 KB
testcase_16 AC 118 ms
98,572 KB
testcase_17 AC 220 ms
158,192 KB
testcase_18 AC 71 ms
71,236 KB
testcase_19 AC 71 ms
71,320 KB
testcase_20 AC 81 ms
76,828 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