QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#621416 | #7318. Cute Panda | N_z_ | WA | 7ms | 3780kb | C++20 | 687b | 2024-10-08 14:22:00 | 2024-10-08 14:22:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
vector<int>a(n),b(n);
for(int x=0;x<n;x++)
cin>>a[x];
for(int x=0;x<n;x++)
cin>>b[x];
vector<long long>f(n),g(n);
f[0]=g[0]=b[0];
for(int x=1;x<n;x++)
{
f[x]=min(f[x-1],g[x-1])+a[x-1];
g[x]=min(f[x],g[x-1])+b[x];
}
long long ans=g[n-1];
f[0]=1e18,g[0]=a[n-1];
for(int x=1;x<n;x++)
{
f[x]=min(f[x-1],g[x-1])+a[x-1];
g[x]=min(f[x],g[x-1])+b[x];
}
cout<<min({ans,f[n-1],g[n-1]})<<'\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3780kb
input:
5 8 4 8 3 10 1 0 4 5 1 5 9 4 10 0 4 3 5 2 2 1
output:
11 13
result:
ok 2 number(s): "11 13"
Test #2:
score: -100
Wrong Answer
time: 7ms
memory: 3468kb
input:
5 6 1 9 8 5 3 1 1 5 5 5 8 7 4 3 6 3 4 3 1 5 5 5 1 4 1 2 5 2 3 0 5 5 7 4 7 5 2 5 3 3 4 1 5 4 1 2 5 5 2 4 1 5 5 5 6 8 4 6 9 4 4 3 3 1 5 3 10 0 6 0 3 1 4 1 3 5 0 6 5 9 10 4 1 5 1 1 5 0 8 1 5 6 0 0 1 4 4 5 4 7 8 8 2 2 1 1 4 1 5 0 10 3 3 8 3 4 3 4 5 5 10 5 9 10 9 4 4 0 2 4 5 8 0 1 7 6 5 3 3 3 3 5 0 6 9 5...
output:
15 16 8 13 17 15 9 12 9 9 19 14 15 7 16 13 15 9 10 17 11 11 12 14 11 8 12 9 6 12 17 13 16 5 12 17 8 14 15 5 12 9 16 15 12 5 12 11 11 16 10 12 1 14 13 8 9 10 11 12 4 5 15 11 12 7 10 9 13 13 5 16 8 10 8 13 14 18 5 11 15 9 6 16 20 8 17 4 12 11 12 18 5 15 12 12 5 10 15 6 15 12 7 15 16 5 16 16 15 17 5 6 ...
result:
wrong answer 3rd numbers differ - expected: '12', found: '8'