結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2017-12-27 17:40:30 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 279 ms / 5,000 ms |
コード長 | 574 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 14,976 KB |
最終ジャッジ日時 | 2024-06-26 10:26:16 |
合計ジャッジ時間 | 2,626 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
n = int(input()) w = list(map(int,input().split())) tt = sum(w) t = int(tt//2) table = [[0 for i in range(t+1)] for k in range(n+1)] for i in range(t+1): if i == 0: table[0][0] = True else: table[0][i] = False if tt%2 != 0: print('impossible') else: for i in range(1,n+1): for k in range(t+1): if table[i-1][k]: table[i][k]=table[i-1][k] elif w[i-1]<=k: if table[i-1][k-w[i-1]]: table[i][k]=table[i-1][k-w[i-1]] else: table[i][k] = False else: table[i][k] = False if table[n][t]: print('possible') else: print('impossible')