General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
95983455 Practice:
ya_hossein
1195C - 18 C++17 (GCC 7-32) Accepted 390 ms 34040 KB 2020-10-19 15:14:41 2020-10-19 15:14:41
→ Source
//besme taala
//ya_hossein
#include<iostream>
using namespace std;
int n;
long long int a[1000000], b[1000000];
long long int t[1000000], g[1000000];
long long int ans1(int x);
long long int ans0(int x)
{
	if(x >= n)
	return 0;
	if(t[x])
	return t[x];
	return (t[x] = a[x] + max(ans1(x + 1), ans1(x + 2)));
}
long long int ans1(int x)
{
	if(x >= n)
	return 0;
	if(g[x])
	return g[x];
	return (g[x] = b[x] + max(ans0(x + 1), ans0(x + 2)));
}
int main()
{
	cin >> n;
	for(int i = 0; i < n; i++)
	cin >> a[i];
	for(int i = 0; i < n; i++)
	cin >> b[i];
	cout << max(ans0(0), ans1(0));
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details