結果

問題 No.4 おもりと天秤
ユーザー otsunekootsuneko
提出日時 2021-04-25 02:14:57
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 476 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 77,260 KB
最終ジャッジ日時 2023-09-17 13:58:49
合計ジャッジ時間 8,660 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,288 KB
testcase_01 AC 75 ms
71,104 KB
testcase_02 AC 109 ms
77,260 KB
testcase_03 AC 77 ms
70,916 KB
testcase_04 AC 74 ms
71,356 KB
testcase_05 AC 75 ms
71,480 KB
testcase_06 AC 76 ms
71,204 KB
testcase_07 AC 76 ms
71,532 KB
testcase_08 AC 75 ms
71,232 KB
testcase_09 AC 73 ms
71,328 KB
testcase_10 AC 73 ms
71,200 KB
testcase_11 AC 72 ms
71,432 KB
testcase_12 AC 73 ms
71,356 KB
testcase_13 AC 73 ms
71,352 KB
testcase_14 AC 72 ms
71,360 KB
testcase_15 AC 73 ms
71,356 KB
testcase_16 AC 74 ms
71,252 KB
testcase_17 AC 75 ms
71,472 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)
def dfs(idx,w):
    if idx == N:
        return
    if w + W[idx] == total_w/2:
        print("possible")
        exit()
    elif w + W[idx] < total_w/2:
        dfs(idx+1,w+W[idx])
        dfs(idx+1,w)
    else:
        dfs(idx+1,w)

N = int(input())
W = list(map(int,input().split()))
total_w = sum(W)

if total_w/2 != total_w//2:
    print("impossible")
    exit()

seen = set([])
dfs(0,0)
print("impossible")
0