結果
問題 |
No.247 線形計画問題もどき
|
ユーザー |
![]() |
提出日時 | 2020-12-22 00:02:43 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 569 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-21 13:23:17 |
合計ジャッジ時間 | 2,173 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 17 WA * 6 |
ソースコード
import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) C = int(input()) N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) cnt = [] def rec(i, val): if i == N - 1: if val % A[i] == 0: cnt.append(val // A[i]) return True return False x_max = val // A[i] for x in reversed(range(x_max + 1)): cnt.append(x) if rec(i + 1, val - A[i] * x): return True cnt.pop() return False rec(0, C) if cnt: print(sum(cnt)) else: print(-1)