提出 #72042554


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n , m;
	cin >> n >> m;
	string s , t;
	cin >> s >> t;
	int p = t.size();
	int minn = 1e9;
	for(int i = 0 ; i < (int)s.size() - p + 1 ; i++){
			int j = i + p - 1;
			int sum = 0;
			for(int k = i , q = 0 ; k <= j ; k++ , q++){
				//cout << s[k] << " " << t[q] << endl;
				if(s[k] < t[q]) sum += 9 - (t[q] - '0') + (s[k] - '0') + 1;
				else sum += (s[k] - '0') - (t[q] - '0');
			}	
			//cout << endl;
			//cout << sum << endl;
			minn = min(minn , sum);

	}
	cout << minn;
    return 0;
}

提出情報

提出日時
問題 B - Substring 2
ユーザ Hacker_
言語 C++23 (GCC 15.2.0)
得点 200
コード長 578 Byte
結果 AC
実行時間 1 ms
メモリ 3620 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 1 ms 3472 KiB
00_sample_01.txt AC 1 ms 3436 KiB
00_sample_02.txt AC 1 ms 3532 KiB
00_sample_03.txt AC 1 ms 3456 KiB
01_random_00.txt AC 1 ms 3584 KiB
01_random_01.txt AC 1 ms 3436 KiB
01_random_02.txt AC 1 ms 3468 KiB
01_random_03.txt AC 1 ms 3436 KiB
01_random_04.txt AC 1 ms 3488 KiB
01_random_05.txt AC 1 ms 3488 KiB
01_random_06.txt AC 1 ms 3556 KiB
01_random_07.txt AC 1 ms 3620 KiB
01_random_08.txt AC 1 ms 3600 KiB
01_random_09.txt AC 1 ms 3488 KiB
01_random_10.txt AC 1 ms 3580 KiB
01_random_11.txt AC 1 ms 3604 KiB
01_random_12.txt AC 1 ms 3604 KiB
01_random_13.txt AC 1 ms 3544 KiB
01_random_14.txt AC 1 ms 3620 KiB
01_random_15.txt AC 1 ms 3580 KiB
01_random_16.txt AC 1 ms 3588 KiB
01_random_17.txt AC 1 ms 3488 KiB