結果

問題 No.636 硬貨の枚数2
ユーザー titiatitia
提出日時 2021-12-12 00:37:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 334 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 10,604 KB
実行使用メモリ 9,228 KB
最終ジャッジ日時 2023-09-27 14:26:39
合計ジャッジ時間 4,205 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,692 KB
testcase_01 AC 16 ms
8,596 KB
testcase_02 AC 17 ms
8,716 KB
testcase_03 AC 17 ms
8,752 KB
testcase_04 AC 16 ms
8,728 KB
testcase_05 AC 17 ms
8,540 KB
testcase_06 AC 16 ms
8,644 KB
testcase_07 AC 17 ms
8,596 KB
testcase_08 AC 16 ms
8,700 KB
testcase_09 AC 16 ms
8,600 KB
testcase_10 AC 16 ms
8,696 KB
testcase_11 AC 20 ms
8,660 KB
testcase_12 AC 16 ms
8,676 KB
testcase_13 AC 17 ms
8,640 KB
testcase_14 AC 17 ms
8,616 KB
testcase_15 AC 17 ms
8,560 KB
testcase_16 AC 16 ms
8,732 KB
testcase_17 AC 16 ms
8,684 KB
testcase_18 AC 16 ms
8,656 KB
testcase_19 AC 16 ms
8,544 KB
testcase_20 AC 17 ms
8,592 KB
testcase_21 AC 16 ms
8,628 KB
testcase_22 AC 17 ms
8,632 KB
testcase_23 AC 16 ms
8,536 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 AC 17 ms
8,608 KB
testcase_55 AC 17 ms
8,544 KB
testcase_56 AC 16 ms
8,568 KB
testcase_57 AC 16 ms
8,656 KB
testcase_58 AC 15 ms
8,540 KB
testcase_59 AC 16 ms
8,672 KB
testcase_60 AC 16 ms
8,656 KB
testcase_61 AC 16 ms
8,608 KB
testcase_62 AC 16 ms
8,540 KB
testcase_63 AC 16 ms
8,564 KB
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=input().strip()
LEN=len(N)

Y=[0,1,2,3,2,1,2,3,3,2,1]

from functools import lru_cache
@lru_cache(maxsize=None)
def calc(i,k):
    if i==-1:
        return k
    if k==0:
        x=int(N[i])
    else:
        x=int(N[i])+1

    ANS=min(Y[x]+calc(i-1,0),Y[10-x]+calc(i-1,1))

    return ANS
        


print(calc(LEN-1,0))
    
    
0