Submission #72027354


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n,m;
    
    string s,t;
    
    ll ans = INT_MAX;
    
    cin >> n >> m >> s >> t;
    
    rep(i,0,n-m+1){
        
        ll a=0;
        
        rep(j,0,m){
            
            ll b = s[i+j]-'0';
            ll c = t[j]-'0';
            
            ll diff = (b-c+10)%10;
            
            a+=diff;
        }
        
        ans = min(ans,a);
    }
    
    cout << ans << endl;
    
}    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    

Submission Info

Submission Time
Task B - Substring 2
User unknown_2406
Language C++23 (GCC 15.2.0)
Score 200
Code Size 5311 Byte
Status AC
Exec Time 1 ms
Memory 3660 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 22
Set Name Test Cases
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
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3488 KiB
00_sample_01.txt AC 1 ms 3616 KiB
00_sample_02.txt AC 1 ms 3600 KiB
00_sample_03.txt AC 1 ms 3584 KiB
01_random_00.txt AC 1 ms 3616 KiB
01_random_01.txt AC 1 ms 3504 KiB
01_random_02.txt AC 1 ms 3624 KiB
01_random_03.txt AC 1 ms 3652 KiB
01_random_04.txt AC 1 ms 3608 KiB
01_random_05.txt AC 1 ms 3528 KiB
01_random_06.txt AC 1 ms 3564 KiB
01_random_07.txt AC 1 ms 3612 KiB
01_random_08.txt AC 1 ms 3592 KiB
01_random_09.txt AC 1 ms 3504 KiB
01_random_10.txt AC 1 ms 3660 KiB
01_random_11.txt AC 1 ms 3596 KiB
01_random_12.txt AC 1 ms 3652 KiB
01_random_13.txt AC 1 ms 3564 KiB
01_random_14.txt AC 1 ms 3624 KiB
01_random_15.txt AC 1 ms 3592 KiB
01_random_16.txt AC 1 ms 3504 KiB
01_random_17.txt AC 1 ms 3476 KiB