結果

問題 No.1594 Three Classes
ユーザー ki_ato_moki_ato_mo
提出日時 2021-07-10 18:49:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,017 ms / 2,000 ms
コード長 753 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 77,720 KB
最終ジャッジ日時 2024-04-28 00:38:59
合計ジャッジ時間 11,781 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,016 ms
77,468 KB
testcase_01 AC 36 ms
51,712 KB
testcase_02 AC 35 ms
51,968 KB
testcase_03 AC 124 ms
77,344 KB
testcase_04 AC 979 ms
77,532 KB
testcase_05 AC 990 ms
77,716 KB
testcase_06 AC 144 ms
77,336 KB
testcase_07 AC 147 ms
77,340 KB
testcase_08 AC 1,017 ms
77,400 KB
testcase_09 AC 1,016 ms
77,464 KB
testcase_10 AC 990 ms
77,712 KB
testcase_11 AC 971 ms
77,656 KB
testcase_12 AC 995 ms
77,564 KB
testcase_13 AC 38 ms
52,864 KB
testcase_14 AC 245 ms
77,720 KB
testcase_15 AC 387 ms
77,236 KB
testcase_16 AC 181 ms
76,692 KB
testcase_17 AC 445 ms
77,332 KB
testcase_18 AC 35 ms
52,224 KB
testcase_19 AC 94 ms
76,120 KB
testcase_20 AC 115 ms
76,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
e = list(map(int, input().split()))
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
for i in range(3 ** n):
    x = list(Base_10_to_n(i, 3))
    a = []
    b = []
    c = []
    for j, k in enumerate(x):
        if k == '0':
            a.append(e[j])
        elif k == '1':
            b.append(e[j])
        else:
            c.append(e[j])
    for j in range(n - len(x)):
        a.append(e[-(j + 1)])
    # check = []
    # check.append(a)
    # check.append(b)
    # check.append(c)
    # print(check)
    if not a or not b or not c:
        continue
    else:
        if sum(a) == sum(b) and sum(b) == sum(c):
            print('Yes')
            exit()
print('No')
0