結果

問題 No.83 最大マッチング
コンテスト
ユーザー dango
提出日時 2023-06-05 21:32:09
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 83 ms / 5,000 ms
+ 12µs
コード長 514 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 56 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 13,696 KB
最終ジャッジ日時 2026-10-09 06:22:52
合計ジャッジ時間 1,715 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
matchsticks = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
min_matchsticks = min(matchsticks)

num_digits = N // min_matchsticks
remaining_matchsticks = N % min_matchsticks

result = [str(matchsticks.index(min_matchsticks))] * num_digits

for i in range(num_digits):
    for j in range(9, -1, -1):
        if matchsticks[j] - min_matchsticks <= remaining_matchsticks:
            result[i] = str(j)
            remaining_matchsticks -= matchsticks[j] - min_matchsticks
            break

print("".join(result))
0