結果

問題 No.1594 Three Classes
ユーザー tnodinotnodino
提出日時 2021-08-08 21:41:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 82,344 KB
実行使用メモリ 76,072 KB
最終ジャッジ日時 2024-04-28 00:42:40
合計ジャッジ時間 3,621 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 250 ms
75,860 KB
testcase_01 AC 35 ms
52,940 KB
testcase_02 AC 33 ms
52,700 KB
testcase_03 AC 44 ms
62,744 KB
testcase_04 AC 254 ms
76,072 KB
testcase_05 AC 242 ms
75,612 KB
testcase_06 AC 47 ms
62,148 KB
testcase_07 AC 53 ms
63,600 KB
testcase_08 AC 250 ms
75,960 KB
testcase_09 AC 245 ms
75,960 KB
testcase_10 AC 243 ms
75,872 KB
testcase_11 AC 242 ms
75,448 KB
testcase_12 AC 243 ms
75,472 KB
testcase_13 AC 35 ms
52,768 KB
testcase_14 AC 83 ms
67,120 KB
testcase_15 AC 65 ms
65,392 KB
testcase_16 AC 53 ms
63,068 KB
testcase_17 AC 48 ms
62,404 KB
testcase_18 AC 34 ms
52,420 KB
testcase_19 AC 44 ms
62,212 KB
testcase_20 AC 41 ms
61,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# No.1594 Three Classes
# https://yukicoder.me/problems/no/1594

# Step #1. 入力
N = int(input())
E = list(map(int,input().split()))

# Step #2. 前処理
power3 = [0] * (N+1)
power3[0] = 1
for i in range(1,N+1):
    power3[i] = 3 * power3[i-1]

# Step #3. 探索
for i in range(power3[N]):
    sumA = 0
    sumB = 0
    sumC = 0
    for j in range(N):
        bit = (i // power3[j]) % 3
        if bit == 0:
            sumA += E[j]
        if bit == 1:
            sumB += E[j]
        if bit == 2:
            sumC += E[j]
    if sumA == sumB and sumB == sumC:
        print('Yes')
        exit()
print('No')
0