結果

問題 No.1594 Three Classes
ユーザー kept1994kept1994
提出日時 2021-08-26 23:42:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 64,384 KB
最終ジャッジ日時 2024-04-28 00:43:05
合計ジャッジ時間 1,607 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
63,360 KB
testcase_01 AC 33 ms
51,584 KB
testcase_02 AC 33 ms
51,968 KB
testcase_03 AC 33 ms
52,480 KB
testcase_04 AC 34 ms
52,096 KB
testcase_05 AC 44 ms
62,720 KB
testcase_06 AC 33 ms
52,224 KB
testcase_07 AC 33 ms
52,608 KB
testcase_08 AC 47 ms
64,384 KB
testcase_09 AC 42 ms
62,848 KB
testcase_10 AC 43 ms
62,464 KB
testcase_11 AC 43 ms
63,104 KB
testcase_12 AC 45 ms
63,104 KB
testcase_13 AC 32 ms
52,224 KB
testcase_14 AC 41 ms
60,928 KB
testcase_15 AC 41 ms
59,904 KB
testcase_16 AC 39 ms
59,264 KB
testcase_17 AC 37 ms
59,044 KB
testcase_18 AC 33 ms
51,968 KB
testcase_19 AC 33 ms
52,096 KB
testcase_20 AC 32 ms
52,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys

def main():
    N = int(input())
    A = list(map(int, input().split()))
    S = sum(A)
    if S % 3 != 0:
        print("No")
        return
    t = S // 3
    l = []
    for i in range(2 ** N):
        c1 = 0
        rest = []
        for b in range(N):
            if i >> b & 1:
                c1 += A[b]
                if c1 > t:
                    break
            else:
                rest.append(A[b])
        if c1 == t:
            for ii in range(2 ** len(rest)):
                c2 = 0
                for bb in range(N):
                    if ii >> bb & 1:
                        c2 += rest[bb]
                        if c2 > t:
                            break
                if c2 == t:
                    print("Yes")
                    return
    print("No")
            

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