結果
問題 | No.2656 XOR Slimes |
ユーザー |
|
提出日時 | 2024-03-01 21:32:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 411 bytes |
コンパイル時間 | 475 ms |
コンパイル使用メモリ | 64,924 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-29 13:33:44 |
合計ジャッジ時間 | 2,483 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 55 |
ソースコード
#include<iostream> #include<cassert> using namespace std; int N; int X[5050],A[5050]; long dist[5050]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N; for(int i=0;i<N;i++)cin>>X[i]; for(int i=0;i<N;i++)cin>>A[i]; for(int i=1;i<=N;i++) { dist[i]=1e18; int a=0; for(int j=i-1;j>=0;j--) { a^=A[j]; dist[i]=min(dist[i],dist[j]+a+X[i-1]-X[j]); } } cout<<dist[N]<<endl; }