結果
問題 | No.2889 Rusk |
ユーザー |
|
提出日時 | 2024-09-14 18:26:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 894 bytes |
コンパイル時間 | 1,803 ms |
コンパイル使用メモリ | 195,260 KB |
最終ジャッジ日時 | 2025-02-24 08:38:12 |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 52 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;template<class T> istream& operator >> (istream& is, vector<T>& vec) {for(T& x : vec) is >> x;return is;}int main(){ios::sync_with_stdio(false);cin.tie(0);int n;cin >> n;vector<int> a(n), b(n), c(n);cin >> a >> b >> c;array<ll, 5> dp{}, dp2{};for(int i = 0; i < n; i++){dp[0] += a[i];dp[1] = max(dp[1] + b[i], dp[0]);dp[2] = max(dp[2] + a[i], dp[1]);dp[3] = max(dp[3] + b[i], dp[2]);dp[4] = max(dp[4] + a[i], dp[3]);dp2[0] += a[i];dp2[1] = max(dp2[1] + b[i], dp2[0]);dp2[2] = max(dp2[2] + c[i], dp2[1]);dp2[3] = max(dp2[3] + b[i], dp2[2]);dp2[4] = max(dp2[4] + a[i], dp2[3]);}cout << max(*max_element(dp.begin(), dp.end()), *max_element(dp2.begin(), dp2.end())) << '\n';}