結果
問題 |
No.27 板の準備
|
ユーザー |
![]() |
提出日時 | 2025-03-20 21:12:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 120 ms / 5,000 ms |
コード長 | 1,122 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 82,760 KB |
実行使用メモリ | 77,184 KB |
最終ジャッジ日時 | 2025-03-20 21:14:13 |
合計ジャッジ時間 | 3,044 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
import itertools def main(): import sys V = list(map(int, sys.stdin.readline().split())) min_total = float('inf') # Generate all combinations of three distinct integers between 1 and 30 for a, b, c in itertools.combinations(range(1, 31), 3): max_target = max(V) dp = [float('inf')] * (max_target + 1) dp[0] = 0 # Base case: 0 length requires 0 boards for i in range(max_target + 1): if dp[i] == float('inf'): continue # Try adding each of the three boards for delta in (a, b, c): next_i = i + delta if next_i <= max_target and dp[next_i] > dp[i] + 1: dp[next_i] = dp[i] + 1 # Check if all target values can be achieved total = 0 valid = True for v in V: if dp[v] == float('inf'): valid = False break total += dp[v] if valid and total < min_total: min_total = total print(min_total) if __name__ == "__main__": main()