結果

問題 No.636 硬貨の枚数2
ユーザー convexineqconvexineq
提出日時 2021-02-26 04:38:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 76,508 KB
最終ジャッジ日時 2024-04-09 19:36:49
合計ジャッジ時間 5,404 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,320 KB
testcase_01 AC 36 ms
51,944 KB
testcase_02 AC 35 ms
54,028 KB
testcase_03 AC 42 ms
52,948 KB
testcase_04 AC 39 ms
52,420 KB
testcase_05 AC 35 ms
52,692 KB
testcase_06 AC 36 ms
52,256 KB
testcase_07 AC 36 ms
53,632 KB
testcase_08 AC 35 ms
52,936 KB
testcase_09 AC 36 ms
52,568 KB
testcase_10 AC 36 ms
52,000 KB
testcase_11 AC 35 ms
52,468 KB
testcase_12 AC 36 ms
52,688 KB
testcase_13 AC 38 ms
52,312 KB
testcase_14 AC 36 ms
51,880 KB
testcase_15 AC 36 ms
53,072 KB
testcase_16 AC 36 ms
52,576 KB
testcase_17 AC 37 ms
52,572 KB
testcase_18 AC 35 ms
52,572 KB
testcase_19 AC 35 ms
53,636 KB
testcase_20 AC 34 ms
52,808 KB
testcase_21 AC 36 ms
52,856 KB
testcase_22 AC 36 ms
53,424 KB
testcase_23 AC 36 ms
53,148 KB
testcase_24 AC 55 ms
66,504 KB
testcase_25 AC 81 ms
75,824 KB
testcase_26 AC 46 ms
61,288 KB
testcase_27 AC 59 ms
68,804 KB
testcase_28 AC 48 ms
63,200 KB
testcase_29 AC 83 ms
76,064 KB
testcase_30 AC 46 ms
62,244 KB
testcase_31 AC 74 ms
74,228 KB
testcase_32 AC 49 ms
62,816 KB
testcase_33 AC 40 ms
53,744 KB
testcase_34 AC 89 ms
75,852 KB
testcase_35 AC 91 ms
76,508 KB
testcase_36 AC 90 ms
75,992 KB
testcase_37 AC 89 ms
75,936 KB
testcase_38 AC 88 ms
76,168 KB
testcase_39 AC 91 ms
75,948 KB
testcase_40 AC 94 ms
76,108 KB
testcase_41 AC 93 ms
75,944 KB
testcase_42 AC 95 ms
75,940 KB
testcase_43 AC 93 ms
75,996 KB
testcase_44 AC 65 ms
71,368 KB
testcase_45 AC 68 ms
72,824 KB
testcase_46 AC 68 ms
71,748 KB
testcase_47 AC 65 ms
70,840 KB
testcase_48 AC 64 ms
71,848 KB
testcase_49 AC 64 ms
71,300 KB
testcase_50 AC 67 ms
71,796 KB
testcase_51 AC 66 ms
72,232 KB
testcase_52 AC 66 ms
73,292 KB
testcase_53 AC 64 ms
70,604 KB
testcase_54 AC 34 ms
52,364 KB
testcase_55 AC 34 ms
52,812 KB
testcase_56 AC 35 ms
52,732 KB
testcase_57 AC 34 ms
53,276 KB
testcase_58 AC 34 ms
52,308 KB
testcase_59 AC 34 ms
53,032 KB
testcase_60 AC 34 ms
53,076 KB
testcase_61 AC 34 ms
52,248 KB
testcase_62 AC 34 ms
52,852 KB
testcase_63 AC 35 ms
52,544 KB
testcase_64 AC 43 ms
61,268 KB
testcase_65 AC 43 ms
61,600 KB
testcase_66 AC 43 ms
61,284 KB
testcase_67 AC 44 ms
60,608 KB
testcase_68 AC 44 ms
60,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = "0"+input()
leq = INF = 1<<30
mor = 0
for i in map(int,s[::-1]):
    nleq = nmor = INF
    # ぴったり、ぴったり-5, 0円、5円
    if i <=9: nmor = min(nmor, mor + (i if i < 5 else 1+(i-5)))
    if i >=5: nleq = min(nleq, mor + 1 + i-5)
    if i > 0: nleq = min(nleq, mor + (10-i if i >= 5 else 1+5-i))
    if i <=5: nmor = min(nmor, mor + 1 + (5-i))
    i += 1
    if i <=9: nmor = min(nmor, leq + (i if i < 5 else 1+(i-5)))
    if i >=5: nleq = min(nleq, leq + 1 + i-5)
    if i > 0: nleq = min(nleq, leq + (10-i if i >= 5 else 1+5-i))
    if i <=5: nmor = min(nmor, leq + 1 + (5-i))
    leq,mor = nleq,nmor
print(mor)
0