結果

問題 No.1594 Three Classes
ユーザー HAPPA
提出日時 2021-07-09 21:35:16
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,016 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-16 07:34:25
合計ジャッジ時間 11,097 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import product

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
MOD = 10 ** 9 + 7


def solve():
    n = int(input())
    E = tuple(map(int, input().split()))

    for pattern in product(range(3), repeat=n):
        P1, P2, P3 = [], [], []
        for i, p in enumerate(pattern):
            P1.append(E[i]) if p == 0 else P2.append(E[i]) if p == 1 else P3.append(E[i])
        if sum(P1) == sum(P2) == sum(P3):
            print("Yes")
            break
    else:
        print("No")


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