結果

問題 No.2196 Pair Bonus
ユーザー ineedyourlovepineedyourlovep
提出日時 2023-01-20 21:59:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 2,127 ms
コンパイル使用メモリ 201,756 KB
実行使用メモリ 7,820 KB
最終ジャッジ日時 2023-09-05 14:16:59
合計ジャッジ時間 4,808 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 234 ms
7,716 KB
testcase_04 AC 234 ms
7,820 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 40 ms
4,376 KB
testcase_09 AC 218 ms
7,396 KB
testcase_10 AC 141 ms
6,184 KB
testcase_11 AC 51 ms
4,376 KB
testcase_12 AC 186 ms
6,600 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 20 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 191 ms
7,440 KB
testcase_17 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 1000000007;
//const int mod = 998244353;

int main()
{
  ll n;
  cin >> n;
  ll n2 = 2*n;
  vector<ll> a(n2), b(n2), x(n), y(n);
  rep(i, 0, n2) cin >> a[i];
  rep(i, 0, n2) cin >> b[i];
  rep(i, 0, n) cin >> x[i];
  rep(i, 0, n) cin >> y[i];
  vector<ll> dp(2);
  rep(i, 0, n2) {
    vector<ll> p = dp;
    dp[0] = max(p[1] + a[i], p[0] + a[i]);
    if (i&1) dp[0] = max({dp[0], p[0] + a[i] + x[i/2], p[1] + a[i] + y[i/2]});
    dp[1] = max(p[0] + b[i], p[1] + b[i]);
    if (i&1) dp[1] = max({dp[1], p[0] + b[i] + y[i/2], p[1] + b[i] + x[i/2]});
  }
  cout << max(dp[0], dp[1]) << endl;
  return 0;
}
0