結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
piconic_X
|
| 提出日時 | 2016-08-21 01:32:11 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 607 bytes |
| コンパイル時間 | 100 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-11-07 21:43:20 |
| 合計ジャッジ時間 | 1,684 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 WA * 8 |
ソースコード
def solve(N, ws, A):
accs = set([0])
for w in ws:
if w > A:
return False
accs_ = set(accs)
for a in accs:
na = w + a
if na == A:
return True
elif na < A:
accs_.add(na)
accs = accs_
return False
def main():
N = int(input())
ws = set(list(map(int, input().split())))
Sum = sum(ws)
if Sum % 2 == 0:
A = Sum // 2
if solve(N, ws, A):
print('possible')
else:
print('impossible')
else:
print('impossible')
main()
piconic_X