結果
問題 | No.4 おもりと天秤 |
ユーザー | mediocreRail |
提出日時 | 2023-08-15 08:34:46 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 181 ms / 5,000 ms |
コード長 | 840 bytes |
コンパイル時間 | 157 ms |
コンパイル使用メモリ | 10,864 KB |
実行使用メモリ | 9,100 KB |
最終ジャッジ日時 | 2023-08-15 08:34:49 |
合計ジャッジ時間 | 2,952 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
9,052 KB |
testcase_01 | AC | 20 ms
8,780 KB |
testcase_02 | AC | 35 ms
9,032 KB |
testcase_03 | AC | 31 ms
8,980 KB |
testcase_04 | AC | 36 ms
8,956 KB |
testcase_05 | AC | 142 ms
9,048 KB |
testcase_06 | AC | 25 ms
8,864 KB |
testcase_07 | AC | 142 ms
8,912 KB |
testcase_08 | AC | 21 ms
8,908 KB |
testcase_09 | AC | 115 ms
9,028 KB |
testcase_10 | AC | 181 ms
8,904 KB |
testcase_11 | AC | 28 ms
9,008 KB |
testcase_12 | AC | 24 ms
9,084 KB |
testcase_13 | AC | 24 ms
8,964 KB |
testcase_14 | AC | 26 ms
8,900 KB |
testcase_15 | AC | 24 ms
8,980 KB |
testcase_16 | AC | 29 ms
8,896 KB |
testcase_17 | AC | 28 ms
8,884 KB |
testcase_18 | AC | 125 ms
9,036 KB |
testcase_19 | AC | 142 ms
9,100 KB |
testcase_20 | AC | 137 ms
9,100 KB |
testcase_21 | AC | 139 ms
8,896 KB |
testcase_22 | AC | 162 ms
9,080 KB |
ソースコード
import bisect,collections,itertools,math,functools,heapq import sys #sys.setrecursionlimit(10**6) def I(): return int(sys.stdin.readline().rstrip()) def IN(): return int(input()) def LIN(): return list(map(int, input().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LF(): return list(map(float,sys.stdin.readline().rstrip().split())) def SI(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) """ 方針 dp """ N=I() W=LI() W.sort() sa = sum(W) if sa%2!=0: print('impossible') exit() dp = [False]*(11000) dp[0] = True for i in range(N): w = W[i] np = dp.copy() for j in range(10050): if dp[j]: np[j] = True np[w+j] = True dp = np if dp[sa//2]: print('possible') else: print('impossible')