結果
| 問題 |
No.2656 XOR Slimes
|
| コンテスト | |
| ユーザー |
kokosei
|
| 提出日時 | 2024-03-02 12:10:17 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| コード長 | 773 bytes |
| コンパイル時間 | 2,979 ms |
| コンパイル使用メモリ | 244,120 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-29 15:54:49 |
| 合計ジャッジ時間 | 4,610 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 55 |
コンパイルメッセージ
main.cpp:4:27: warning: integer overflow in expression of type 'int' results in '2147483647' [-Woverflow]
4 | const int inf = (1 << 31) - 1;
| ~~~~~~~~~~^~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = (1 << 31) - 1;
int N;
int X[5010], A[5010];
ll dp[5010];
template<typename A, int N, typename T>
void Fill(A (&arr)[N], const T &val){
fill((T*)arr, (T*)(arr + N), val);
}
template<typename T>
void chmin(T &a, T b){
a = min(a, b);
}
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N;
for(int i = 0;i < N;i++)cin >> X[i];
for(int i = 1;i <= N;i++)cin >> A[i];
for(int i = 0;i < N;i++)A[i + 1] ^= A[i];
Fill(dp, inf);
dp[0] = 0;
for(int i = 0;i < N;i++){
for(int j = i + 1;j <= N;j++){
chmin(dp[j], dp[i] + X[j - 1] - X[i] + (A[j] ^ A[i]));
}
}
cout << dp[N] << endl;
return 0;
}
kokosei