結果
問題 | No.2889 Rusk |
ユーザー | maeshun |
提出日時 | 2024-09-14 12:09:24 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 309 ms / 2,000 ms |
コード長 | 2,984 bytes |
コンパイル時間 | 4,739 ms |
コンパイル使用メモリ | 266,584 KB |
実行使用メモリ | 39,936 KB |
最終ジャッジ日時 | 2024-09-14 12:09:40 |
合計ジャッジ時間 | 15,002 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 3 ms
5,376 KB |
testcase_06 | AC | 3 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 3 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 3 ms
5,376 KB |
testcase_13 | AC | 3 ms
5,376 KB |
testcase_14 | AC | 13 ms
5,376 KB |
testcase_15 | AC | 50 ms
9,088 KB |
testcase_16 | AC | 130 ms
18,432 KB |
testcase_17 | AC | 35 ms
7,296 KB |
testcase_18 | AC | 101 ms
16,000 KB |
testcase_19 | AC | 194 ms
28,160 KB |
testcase_20 | AC | 239 ms
33,792 KB |
testcase_21 | AC | 198 ms
28,288 KB |
testcase_22 | AC | 167 ms
24,576 KB |
testcase_23 | AC | 137 ms
19,968 KB |
testcase_24 | AC | 240 ms
33,664 KB |
testcase_25 | AC | 133 ms
19,712 KB |
testcase_26 | AC | 195 ms
27,520 KB |
testcase_27 | AC | 249 ms
34,688 KB |
testcase_28 | AC | 147 ms
21,760 KB |
testcase_29 | AC | 152 ms
22,400 KB |
testcase_30 | AC | 157 ms
22,272 KB |
testcase_31 | AC | 249 ms
34,304 KB |
testcase_32 | AC | 106 ms
16,512 KB |
testcase_33 | AC | 31 ms
6,784 KB |
testcase_34 | AC | 290 ms
39,936 KB |
testcase_35 | AC | 291 ms
39,936 KB |
testcase_36 | AC | 289 ms
39,936 KB |
testcase_37 | AC | 287 ms
39,936 KB |
testcase_38 | AC | 290 ms
39,936 KB |
testcase_39 | AC | 127 ms
36,608 KB |
testcase_40 | AC | 99 ms
29,184 KB |
testcase_41 | AC | 132 ms
38,144 KB |
testcase_42 | AC | 91 ms
27,392 KB |
testcase_43 | AC | 44 ms
14,336 KB |
testcase_44 | AC | 118 ms
34,432 KB |
testcase_45 | AC | 91 ms
27,008 KB |
testcase_46 | AC | 27 ms
9,856 KB |
testcase_47 | AC | 48 ms
15,360 KB |
testcase_48 | AC | 106 ms
31,232 KB |
testcase_49 | AC | 2 ms
5,376 KB |
testcase_50 | AC | 2 ms
5,376 KB |
testcase_51 | AC | 2 ms
5,376 KB |
testcase_52 | AC | 2 ms
5,376 KB |
testcase_53 | AC | 2 ms
5,376 KB |
testcase_54 | AC | 309 ms
39,936 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i, n) for(int i=0;i<(n);++i) #define rep1(i, n) for(int i=1;i<=(n);i++) #define ll long long using mint = modint998244353; using P = pair<ll,ll>; using lb = long double; using T = tuple<ll, ll, ll>; #ifdef LOCAL # include <debug_print.hpp> # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast<void>(0)) #endif int main() { int n; cin >> n; vector<int> a(n),b(n),c(n); rep(i,n) cin >> a[i]; rep(i,n) cin >> b[i]; rep(i,n) cin >> c[i]; vector<vector<ll>> dp(n+1, vector<ll>(6)); auto fp = dp; rep(i,n) { dp[i+1][1] = max(dp[i+1][1], dp[i][0]+a[i]); dp[i+1][1] = max(dp[i+1][1], dp[i][1]+a[i]); dp[i+1][2] = max(dp[i+1][2], dp[i][0]+b[i]); dp[i+1][2] = max(dp[i+1][2], dp[i][1]+b[i]); dp[i+1][2] = max(dp[i+1][2], dp[i][2]+b[i]); dp[i+1][3] = max(dp[i+1][3], dp[i][0]+c[i]); dp[i+1][3] = max(dp[i+1][3], dp[i][1]+c[i]); dp[i+1][3] = max(dp[i+1][3], dp[i][2]+c[i]); dp[i+1][3] = max(dp[i+1][3], dp[i][3]+c[i]); dp[i+1][4] = max(dp[i+1][4], dp[i][0]+b[i]); dp[i+1][4] = max(dp[i+1][4], dp[i][1]+b[i]); dp[i+1][4] = max(dp[i+1][4], dp[i][2]+b[i]); dp[i+1][4] = max(dp[i+1][4], dp[i][3]+b[i]); dp[i+1][4] = max(dp[i+1][4], dp[i][4]+b[i]); dp[i+1][5] = max(dp[i+1][5], dp[i][0]+a[i]); dp[i+1][5] = max(dp[i+1][5], dp[i][1]+a[i]); dp[i+1][5] = max(dp[i+1][5], dp[i][2]+a[i]); dp[i+1][5] = max(dp[i+1][5], dp[i][3]+a[i]); dp[i+1][5] = max(dp[i+1][5], dp[i][4]+a[i]); dp[i+1][5] = max(dp[i+1][5], dp[i][5]+a[i]); } ll ans = 0; rep(i,6) ans = max(ans, dp[n][i]); rep(i,n) { fp[i+1][1] = max(fp[i+1][1], fp[i][0]+a[i]); fp[i+1][1] = max(fp[i+1][1], fp[i][1]+a[i]); fp[i+1][2] = max(fp[i+1][2], fp[i][0]+b[i]); fp[i+1][2] = max(fp[i+1][2], fp[i][1]+b[i]); fp[i+1][2] = max(fp[i+1][2], fp[i][2]+b[i]); fp[i+1][3] = max(fp[i+1][3], fp[i][0]+a[i]); fp[i+1][3] = max(fp[i+1][3], fp[i][1]+a[i]); fp[i+1][3] = max(fp[i+1][3], fp[i][2]+a[i]); fp[i+1][3] = max(fp[i+1][3], fp[i][3]+a[i]); fp[i+1][4] = max(fp[i+1][4], fp[i][0]+b[i]); fp[i+1][4] = max(fp[i+1][4], fp[i][1]+b[i]); fp[i+1][4] = max(fp[i+1][4], fp[i][2]+b[i]); fp[i+1][4] = max(fp[i+1][4], fp[i][3]+b[i]); fp[i+1][4] = max(fp[i+1][4], fp[i][4]+b[i]); fp[i+1][5] = max(fp[i+1][5], fp[i][0]+a[i]); fp[i+1][5] = max(fp[i+1][5], fp[i][1]+a[i]); fp[i+1][5] = max(fp[i+1][5], fp[i][2]+a[i]); fp[i+1][5] = max(fp[i+1][5], fp[i][3]+a[i]); fp[i+1][5] = max(fp[i+1][5], fp[i][4]+a[i]); fp[i+1][5] = max(fp[i+1][5], fp[i][5]+a[i]); } rep(i,6) ans = max(ans, fp[n][i]); cout << ans << endl; return 0; }