Submission #20388

#TimeUsernameProblemLanguageResultExecution timeMemory
20388윤지학 (#35)Can polan into space? (OJUZ11_space)C++98
100 / 100
146 ms15836 KiB
#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)

space.cpp: In function 'int main()':
space.cpp:36:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
space.cpp:37:63: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = 1; i <= n; i++) scanf("%d%d%d", &a[i], &b[i], &c[i]);
                                                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...