# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20749 | eaststar | Can polan into space? (OJUZ11_space) | C++11 | 146 ms | 17404 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
int a[200010][3],p[2][200010];
long long D[2][200010];
void f(int t,int n){
if(!n)return;
if(p[t][n])printf("%d ",n);
f(p[t][n],n-1);
if(!p[t][n])printf("%d ",n);
}
int main(){
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;++i){
for(j=0;j<3;++j)scanf("%d",a[i]+j);
}
D[0][1]=a[1][0],D[1][1]=a[1][1];
for(i=2;i<=n;++i){
for(j=0;j<2;++j){
if(a[i][j]+D[1][i-1]>a[i][j+1]+D[0][i-1])D[j][i]=a[i][j]+D[1][i-1],p[j][i]=1;
else D[j][i]=a[i][j+1]+D[0][i-1];
}
}
printf("%lld\n",D[0][n]);
f(0,n);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |