# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20388 | 윤지학 (#35) | Can polan into space? (OJUZ11_space) | C++98 | 146 ms | 15836 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 <cstdio>
#include <algorithm>
using namespace std;
int a[200002], b[200002], c[200002];
long long d[200002], e[200002];
void f(int x, int y) {
if (x == 1) {
printf("1 ");
return;
}
if (y) {
if (e[x] == d[x - 1] + c[x]) {
f(x - 1, 0);
printf("%d ", x);
return;
}
printf("%d ", x);
f(x - 1, 1);
return;
}
if (d[x] == d[x - 1] + b[x]) {
f(x - 1, 0);
printf("%d ", x);
return;
}
printf("%d ", x);
f(x - 1, 1);
return;
}
int main() {
int i, n;
scanf("%d", &n);
for (i = 1; i <= n; i++) scanf("%d%d%d", &a[i], &b[i], &c[i]);
d[1] = a[1];
e[1] = b[1];
for (i = 2; i <= n; i++) {
d[i] = max(d[i - 1] + b[i], e[i - 1] + a[i]);
e[i] = max(d[i - 1] + c[i], e[i - 1] + b[i]);
}
printf("%lld\n", d[n]);
f(n, 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... |