提出 #72013286


ソースコード 拡げる

n ,m = map(int,input().split())
s = input()
t = input()

kaisuu = 0
ans = 10000
for i in range(n-m+1):
    kaisuu = 0
    for k in range(m):
        #print(s[k+i], t[k])
        if int(s[k+i]) < int(t[k]):
            kaisuu += int(s[k+i])+10-int(t[k])
        else:
            kaisuu += int(s[k+i]) - int(t[k])
    #print(kaisuu)
    if ans > kaisuu:
        ans = kaisuu
print(ans)

提出情報

提出日時
問題 B - Substring 2
ユーザ hayahaya11
言語 Python (PyPy 3.11-v7.3.20)
得点 200
コード長 403 Byte
結果 AC
実行時間 58 ms
メモリ 87692 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 4
AC × 22
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 51 ms 79848 KiB
00_sample_01.txt AC 51 ms 79868 KiB
00_sample_02.txt AC 51 ms 79644 KiB
00_sample_03.txt AC 51 ms 79732 KiB
01_random_00.txt AC 51 ms 79612 KiB
01_random_01.txt AC 51 ms 79996 KiB
01_random_02.txt AC 51 ms 79524 KiB
01_random_03.txt AC 51 ms 79848 KiB
01_random_04.txt AC 51 ms 79848 KiB
01_random_05.txt AC 58 ms 87692 KiB
01_random_06.txt AC 52 ms 80548 KiB
01_random_07.txt AC 52 ms 80124 KiB
01_random_08.txt AC 51 ms 79976 KiB
01_random_09.txt AC 52 ms 80332 KiB
01_random_10.txt AC 51 ms 79572 KiB
01_random_11.txt AC 56 ms 87512 KiB
01_random_12.txt AC 51 ms 80028 KiB
01_random_13.txt AC 52 ms 80312 KiB
01_random_14.txt AC 51 ms 79784 KiB
01_random_15.txt AC 51 ms 79784 KiB
01_random_16.txt AC 51 ms 79732 KiB
01_random_17.txt AC 51 ms 79976 KiB