結果
| 問題 |
No.999 てん vs. ほむ
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-10-19 16:16:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 599 bytes |
| コンパイル時間 | 1,928 ms |
| コンパイル使用メモリ | 204,320 KB |
| 実行使用メモリ | 140,836 KB |
| 最終ジャッジ日時 | 2025-10-19 16:16:33 |
| 合計ジャッジ時間 | 6,137 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 TLE * 1 -- * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int N;
vector<long long> A;
map<pair<int,int>, long long> memo;
long long f(int l, int r) {
if (l >= r) return 0;
auto key = make_pair(l, r);
if (memo.count(key)) return memo[key];
long long res = max(
A[l] - A[l + 1] + f(l + 2, r),
A[r] - A[r - 1] + f(l, r - 2)
);
memo[key] = res;
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N;
A.resize(2 * N);
for (int i = 0; i < 2 * N; i++) cin >> A[i];
cout << f(0, 2 * N - 1) << "\n";
return 0;
}
norioc