結果

問題 No.2889 Rusk
ユーザー 👑 kmjpkmjp
提出日時 2024-09-13 22:59:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 1,412 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 203,140 KB
実行使用メモリ 20,088 KB
最終ジャッジ日時 2024-09-13 22:59:34
合計ジャッジ時間 6,945 ms
ジャッジサーバーID
(参考情報)
judge4 / judge6
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 2 ms
7,648 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 6 ms
6,940 KB
testcase_15 AC 21 ms
7,784 KB
testcase_16 AC 49 ms
11,696 KB
testcase_17 AC 15 ms
7,012 KB
testcase_18 AC 41 ms
10,468 KB
testcase_19 AC 78 ms
16,016 KB
testcase_20 AC 96 ms
18,292 KB
testcase_21 AC 79 ms
15,744 KB
testcase_22 AC 68 ms
14,588 KB
testcase_23 AC 53 ms
12,132 KB
testcase_24 AC 94 ms
17,900 KB
testcase_25 AC 52 ms
12,588 KB
testcase_26 AC 76 ms
15,732 KB
testcase_27 AC 98 ms
18,312 KB
testcase_28 AC 59 ms
12,516 KB
testcase_29 AC 62 ms
13,188 KB
testcase_30 AC 60 ms
13,316 KB
testcase_31 AC 97 ms
18,048 KB
testcase_32 AC 43 ms
10,472 KB
testcase_33 AC 14 ms
6,940 KB
testcase_34 AC 114 ms
20,088 KB
testcase_35 AC 112 ms
19,976 KB
testcase_36 AC 114 ms
19,940 KB
testcase_37 AC 112 ms
19,932 KB
testcase_38 AC 112 ms
19,940 KB
testcase_39 AC 72 ms
18,404 KB
testcase_40 AC 56 ms
15,892 KB
testcase_41 AC 73 ms
19,300 KB
testcase_42 AC 53 ms
15,596 KB
testcase_43 AC 25 ms
9,700 KB
testcase_44 AC 67 ms
17,892 KB
testcase_45 AC 52 ms
15,336 KB
testcase_46 AC 17 ms
7,908 KB
testcase_47 AC 28 ms
10,080 KB
testcase_48 AC 60 ms
17,084 KB
testcase_49 AC 2 ms
6,944 KB
testcase_50 AC 3 ms
6,940 KB
testcase_51 AC 2 ms
6,940 KB
testcase_52 AC 2 ms
6,940 KB
testcase_53 AC 2 ms
6,940 KB
testcase_54 AC 116 ms
19,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------


int N;
int A[202020],B[202020],C[202020];
ll dp[202020][3][3];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	FOR(i,N) cin>>B[i];
	FOR(i,N) cin>>C[i];
	FOR(i,N) {
		FOR(j,3) FOR(k,3) for(x=j;x<3;x++) for(y=k;y<3;y++) {
			if(x==1&&y==1) dp[i+1][x][y]=max(dp[i+1][x][y],dp[i][j][k]+C[i]);
			if(x==1&&y!=1) dp[i+1][x][y]=max(dp[i+1][x][y],dp[i][j][k]+B[i]);
			if(x!=1&&y==1) dp[i+1][x][y]=max(dp[i+1][x][y],dp[i][j][k]+B[i]);
			if(x!=1&&y!=1) dp[i+1][x][y]=max(dp[i+1][x][y],dp[i][j][k]+A[i]);
		}
	}
	ll ret=0;
	FOR(x,3) FOR(y,3) ret=max(ret,dp[N][x][y]);
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0