結果

問題 No.2656 XOR Slimes
ユーザー cho435cho435
提出日時 2024-03-05 23:36:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 391 ms / 2,000 ms
コード長 611 bytes
コンパイル時間 4,707 ms
コンパイル使用メモリ 265,584 KB
実行使用メモリ 199,296 KB
最終ジャッジ日時 2024-03-05 23:37:01
合計ジャッジ時間 25,401 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 1 ms
6,548 KB
testcase_08 AC 367 ms
199,168 KB
testcase_09 AC 355 ms
199,296 KB
testcase_10 AC 372 ms
199,168 KB
testcase_11 AC 356 ms
199,168 KB
testcase_12 AC 355 ms
199,168 KB
testcase_13 AC 368 ms
199,296 KB
testcase_14 AC 357 ms
199,168 KB
testcase_15 AC 358 ms
199,296 KB
testcase_16 AC 364 ms
199,296 KB
testcase_17 AC 383 ms
199,296 KB
testcase_18 AC 360 ms
199,168 KB
testcase_19 AC 357 ms
199,296 KB
testcase_20 AC 386 ms
199,296 KB
testcase_21 AC 360 ms
199,296 KB
testcase_22 AC 360 ms
199,168 KB
testcase_23 AC 391 ms
199,296 KB
testcase_24 AC 358 ms
199,296 KB
testcase_25 AC 359 ms
199,296 KB
testcase_26 AC 383 ms
199,168 KB
testcase_27 AC 360 ms
199,168 KB
testcase_28 AC 365 ms
199,296 KB
testcase_29 AC 359 ms
199,168 KB
testcase_30 AC 374 ms
199,296 KB
testcase_31 AC 355 ms
199,296 KB
testcase_32 AC 357 ms
199,296 KB
testcase_33 AC 370 ms
199,168 KB
testcase_34 AC 359 ms
199,296 KB
testcase_35 AC 359 ms
199,168 KB
testcase_36 AC 388 ms
199,168 KB
testcase_37 AC 359 ms
199,168 KB
testcase_38 AC 357 ms
199,296 KB
testcase_39 AC 387 ms
199,296 KB
testcase_40 AC 361 ms
199,168 KB
testcase_41 AC 358 ms
199,168 KB
testcase_42 AC 384 ms
199,168 KB
testcase_43 AC 360 ms
199,296 KB
testcase_44 AC 361 ms
199,168 KB
testcase_45 AC 359 ms
199,168 KB
testcase_46 AC 365 ms
199,168 KB
testcase_47 AC 358 ms
199,296 KB
testcase_48 AC 361 ms
199,168 KB
testcase_49 AC 371 ms
199,168 KB
testcase_50 AC 359 ms
199,168 KB
testcase_51 AC 360 ms
199,296 KB
testcase_52 AC 372 ms
199,168 KB
testcase_53 AC 363 ms
199,168 KB
testcase_54 AC 360 ms
199,168 KB
testcase_55 AC 372 ms
199,168 KB
testcase_56 AC 356 ms
199,296 KB
testcase_57 AC 357 ms
199,296 KB
testcase_58 AC 385 ms
199,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
	int n;
	cin>>n;
	vector<int> x(n),a(n);
	rep(i,n) cin>>x.at(i);
	rep(i,n) cin>>a.at(i);
	vector<ll> sa(n+1,0);
	rep(i,n) sa.at(i+1)=sa.at(i)^a.at(i);
	vector<vector<ll>> cs(n+1,vector<ll>(n+1,0));
	rep(i,n) for(int j=i+1;j<=n;j++){
		cs.at(i).at(j)=(sa.at(i)^sa.at(j))+x.at(j-1)-x.at(i);
	}
	vector<ll> dp(n+1,1e18);
	dp.at(0)=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<i;j++){
			dp.at(i)=min(dp.at(i),dp.at(j)+cs.at(j).at(i));
		}
	}
	cout<<dp.at(n)<<endl;
}
0