結果
| 問題 |
No.2656 XOR Slimes
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-04-25 17:23:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 2,000 ms |
| コード長 | 804 bytes |
| コンパイル時間 | 372 ms |
| コンパイル使用メモリ | 42,184 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 04:39:02 |
| 合計ジャッジ時間 | 3,449 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 55 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2656.cc: No.2656 XOR Slimes - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 5000;
const long long LINF = 1LL << 62;
/* typedef */
typedef long long ll;
/* global variables */
int xs[MAX_N], as[MAX_N];
int ass[MAX_N + 1];
ll dp[MAX_N + 1];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", xs + i);
for (int i = 0; i < n; i++) scanf("%d", as + i);
for (int i = 0; i < n; i++) ass[i + 1] = ass[i] ^ as[i];
for (int i = 0; i < n; i++) {
ll mind = LINF;
for (int j = 0; j <= i; j++)
mind = min(mind, dp[j] + (ass[i + 1] ^ ass[j]) + (xs[i] - xs[j]));
dp[i + 1] = mind;
}
printf("%lld\n", dp[n]);
return 0;
}
tnakao0123