結果

問題 No.4 おもりと天秤
ユーザー ゆるくゆるく
提出日時 2014-11-09 01:38:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 380 ms / 5,000 ms
コード長 443 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 10,616 KB
最終ジャッジ日時 2023-09-08 16:03:55
合計ジャッジ時間 5,958 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
10,492 KB
testcase_01 AC 49 ms
10,396 KB
testcase_02 AC 86 ms
10,468 KB
testcase_03 AC 65 ms
10,496 KB
testcase_04 AC 83 ms
10,468 KB
testcase_05 AC 374 ms
10,456 KB
testcase_06 AC 38 ms
10,444 KB
testcase_07 AC 368 ms
10,500 KB
testcase_08 AC 366 ms
10,556 KB
testcase_09 AC 379 ms
10,588 KB
testcase_10 AC 364 ms
10,456 KB
testcase_11 AC 56 ms
10,416 KB
testcase_12 AC 43 ms
10,444 KB
testcase_13 AC 42 ms
10,544 KB
testcase_14 AC 44 ms
10,584 KB
testcase_15 AC 41 ms
10,472 KB
testcase_16 AC 57 ms
10,492 KB
testcase_17 AC 55 ms
10,552 KB
testcase_18 AC 366 ms
10,504 KB
testcase_19 AC 376 ms
10,484 KB
testcase_20 AC 377 ms
10,568 KB
testcase_21 AC 373 ms
10,616 KB
testcase_22 AC 380 ms
10,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy

d = defaultdict(int)
n = int(input())
w = tuple(int(i) for i in input().split())
s = sum(w)

d[0] = 1
for ww in w:
  for i in range(10000, -1, -1):
    d[i + ww] |= d[i]

print("possible" if s % 2 == 0 and d[s / 2] else "impossible")
0