結果

問題 No.83 最大マッチング
ユーザー dangodango
提出日時 2023-06-05 21:32:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 106 ms / 5,000 ms
コード長 514 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,616 KB
実行使用メモリ 11,844 KB
最終ジャッジ日時 2023-08-28 09:43:48
合計ジャッジ時間 1,362 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,776 KB
testcase_01 AC 15 ms
7,764 KB
testcase_02 AC 15 ms
7,756 KB
testcase_03 AC 16 ms
7,776 KB
testcase_04 AC 17 ms
7,764 KB
testcase_05 AC 15 ms
7,812 KB
testcase_06 AC 14 ms
7,828 KB
testcase_07 AC 14 ms
7,884 KB
testcase_08 AC 15 ms
7,796 KB
testcase_09 AC 24 ms
8,208 KB
testcase_10 AC 81 ms
10,700 KB
testcase_11 AC 105 ms
11,844 KB
testcase_12 AC 106 ms
11,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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