結果

問題 No.1594 Three Classes
ユーザー moharan627moharan627
提出日時 2021-07-09 21:48:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 1,056 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 75,904 KB
最終ジャッジ日時 2024-04-28 00:07:49
合計ジャッジ時間 3,434 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
75,340 KB
testcase_01 AC 39 ms
51,840 KB
testcase_02 AC 39 ms
51,840 KB
testcase_03 AC 149 ms
75,520 KB
testcase_04 AC 148 ms
75,648 KB
testcase_05 AC 145 ms
75,264 KB
testcase_06 AC 147 ms
75,392 KB
testcase_07 AC 147 ms
75,616 KB
testcase_08 AC 145 ms
75,520 KB
testcase_09 AC 143 ms
75,740 KB
testcase_10 AC 143 ms
75,520 KB
testcase_11 AC 144 ms
75,860 KB
testcase_12 AC 143 ms
75,276 KB
testcase_13 AC 50 ms
62,192 KB
testcase_14 AC 144 ms
75,904 KB
testcase_15 AC 145 ms
75,408 KB
testcase_16 AC 87 ms
75,776 KB
testcase_17 AC 146 ms
75,520 KB
testcase_18 AC 43 ms
58,240 KB
testcase_19 AC 52 ms
62,976 KB
testcase_20 AC 54 ms
72,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
INF = float('inf')
#10**20,2**63,float('inf')
MOD = 10**9 + 7
MOD2 = 998244353
#from collections import defaultdict
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(input())
    def IC(): return [int(c) for c in input()]
    def MI(): return map(int, sys.stdin.readline().split())
    N = II()
    E = LI()
    flag = False
    for bit3 in range(3**N):
        P = [0] * 3
        Label = []
        # 10進から8進へ
        if (bit3 == 0):
            Label.append(0)
        while bit3:
            bit3, R = divmod(bit3, 3)
            Label.append(R)

        if(len(Label)<N):
            Label = [0]*(N-len(Label))+Label
        #print(Label)
        for i,l in enumerate(Label):
            P[l] += E[i]
        if(P[0] == P[1] == P[2]):
            flag = True
    if flag:
        print("Yes")
    else:
        print("No")
    return
solve()
#sys.setrecursionlimit(10 ** 6)#再帰関数ではコメントにしないこと!!
0