結果
| 問題 | 
                            No.2603 Tone Correction
                             | 
                    
| コンテスト | |
| ユーザー | 
                             沙耶花
                         | 
                    
| 提出日時 | 2024-01-12 22:00:20 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 882 bytes | 
| コンパイル時間 | 4,438 ms | 
| コンパイル使用メモリ | 251,700 KB | 
| 最終ジャッジ日時 | 2025-02-18 18:14:31 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 13 WA * 20 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |         rep(i,n)scanf("%lld",&a[i]);
      |                 ~~~~~^~~~~~~~~~~~~~
main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         rep(i,n)scanf("%lld",&b[i]);
      |                 ~~~~~^~~~~~~~~~~~~~
            
            ソースコード
#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;
}
            
            
            
        
            
沙耶花