結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2023-08-15 08:34:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 166 ms / 5,000 ms |
コード長 | 840 bytes |
コンパイル時間 | 177 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-11-23 14:25:49 |
合計ジャッジ時間 | 2,976 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
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')