結果

問題 No.2603 Tone Correction
ユーザー 沙耶花沙耶花
提出日時 2024-01-12 22:00:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 882 bytes
コンパイル時間 4,599 ms
コンパイル使用メモリ 264,872 KB
実行使用メモリ 9,476 KB
最終ジャッジ日時 2024-01-12 22:00:41
合計ジャッジ時間 20,143 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 12 ms
6,676 KB
testcase_04 AC 11 ms
6,676 KB
testcase_05 AC 11 ms
6,676 KB
testcase_06 AC 11 ms
6,676 KB
testcase_07 AC 12 ms
6,676 KB
testcase_08 AC 11 ms
6,676 KB
testcase_09 AC 11 ms
6,676 KB
testcase_10 AC 11 ms
6,676 KB
testcase_11 AC 11 ms
6,676 KB
testcase_12 AC 11 ms
6,676 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
6,676 KB
testcase_34 AC 633 ms
9,476 KB
testcase_35 AC 612 ms
9,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001


int main(){
	
	long long n,m;
	cin>>n>>m;
	vector<long long> a(n),b(n);
	rep(i,n)scanf("%lld",&a[i]);
	rep(i,n)scanf("%lld",&b[i]);
	
	rep(i,n){
		a[i] -= b[i];
		a[i] += m;
		a[i] %= m;
	}
	a.insert(a.begin(),0LL);
	a.push_back(0);
	vector<long long> dp(40,Inf64);
	dp[dp.size()/2] = 0;
	for(int i=1;i<a.size();i++){
		vector<long long> ndp(40,Inf64);
		rep(j,dp.size()){
			long long x = a[i-1];
			x -= m;
			x += m*j;
			rep(k,dp.size()){
				long long y = a[i];
				y -= m;
				y += m*k;
				ndp[k] = min(ndp[k],dp[j] + abs(x-y));
			}
		}
		swap(dp,ndp);
	}
	long long ans = dp[dp.size()/2];
	cout<<ans/2<<endl;
	return 0;
}
0