QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#354457#4931. Comic Bingea999999#WA 0ms3688kbC++14985b2024-03-15 13:49:472024-03-15 13:49:47

Judging History

你现在查看的是最新测评结果

  • [2024-03-15 13:49:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3688kb
  • [2024-03-15 13:49:47]
  • 提交

answer

#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
const int N=1100;
ll f[N][2],g[N][2],a[N],b[N];
int n;
signed main(int argc,char **argv){
	// freopen("order.in","r",stdin);
	// freopen("order.out","w",stdout);
	cin.tie(nullptr)->sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=n;++i)
		cin>>b[i];
	g[1][0]=b[1];
	g[2][0]=b[1]+b[2];
	g[1][1]=0;
	g[2][1]=b[1];
	for(int i=3;i<=n;++i){
		g[i][0]=min(g[i-1][0],g[i-1][1])+b[i];
		g[i][1]=g[i-1][0];
	}
	for(int i=1;i<=n;++i){
		f[i][0]=max(g[i][0],min(f[i-1][0],f[i-1][1]))+a[i];
		f[i][1]=max(g[i][1],f[i-1][1])+a[i];
	}
	cout<<f[n][0]<<endl;
	// for(int i=1;i<=n;++i)
	// 	cout<<g[i][0]<<' ';
	// cout<<endl;
	// for(int i=1;i<=n;++i)
	// 	cout<<g[i][1]<<' ';
	// cout<<endl;
	// for(int i=1;i<=n;++i)
	// 	cout<<f[i][0]<<' ';
	// cout<<endl;
	// for(int i=1;i<=n;++i)
	// 	cout<<f[i][1]<<' ';
	// cout<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3688kb

input:

6
3 1 1 1 1 2
1 5 3 3 7 4

output:

13

result:

ok single line: '13'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3648kb

input:

2
2 1
1 1

output:

3

result:

wrong answer 1st lines differ - expected: '4', found: '3'