結果

問題 No.1594 Three Classes
ユーザー kamomekamome
提出日時 2021-07-09 22:37:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,016 KB
最終ジャッジ日時 2024-04-28 00:31:52
合計ジャッジ時間 3,209 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
75,648 KB
testcase_01 AC 40 ms
51,712 KB
testcase_02 AC 39 ms
52,480 KB
testcase_03 AC 52 ms
65,024 KB
testcase_04 AC 162 ms
76,016 KB
testcase_05 AC 161 ms
75,632 KB
testcase_06 AC 47 ms
60,392 KB
testcase_07 AC 48 ms
62,336 KB
testcase_08 AC 162 ms
75,996 KB
testcase_09 AC 160 ms
75,904 KB
testcase_10 AC 162 ms
75,960 KB
testcase_11 AC 163 ms
75,584 KB
testcase_12 AC 161 ms
75,984 KB
testcase_13 AC 40 ms
52,096 KB
testcase_14 AC 64 ms
72,960 KB
testcase_15 AC 62 ms
71,168 KB
testcase_16 AC 54 ms
65,340 KB
testcase_17 AC 52 ms
63,488 KB
testcase_18 AC 41 ms
52,096 KB
testcase_19 AC 53 ms
61,312 KB
testcase_20 AC 57 ms
60,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


def iter_p_adic(p, n):
    '''
    連続して増加するp進数をリストとして返す。nはリストの長さ
    return
    ----------
    所望のp進数リストを次々返してくれるiterator
    '''
    from itertools import product
    tmp = [range(p)] * n
    return product(*tmp)


# 3桁の4進全探索
iterator = iter_p_adic(3, N)
for idxs in iterator:
    A = 0
    B = 0
    C = 0
    for i in range(N):
        if idxs[i] == 0:
            A += E[i]
        elif idxs[i] == 1:
            B += E[i]
        else:
            C += E[i]
    if A == B == C:
        print("Yes")
        exit()

print("No")
0