제출 #20407

#제출 시각아이디문제언어결과실행 시간메모리
20407Evnormal (#35)Can polan into space? (OJUZ11_space)C++98
100 / 100
159 ms8936 KiB
#include <stdio.h> int N; long long A[200200],B[200200],C[200200]; long long D[200200]; int vi[200200],vj[200200]; long long p; int pi; long long q; int qi,qj; int main() { scanf ("%d",&N); for (int i=1;i<=N;i++) scanf ("%lld %lld %lld",&A[i],&B[i],&C[i]); C[1] = B[1]; B[1] = A[1]; A[1] = 0; C[N] = B[N]; B[N] = A[N]; A[N] = 0; p = B[1]; pi = 0; q = C[1]; qi = 0; qj = 1; D[1] = -1e16; for (int i=2;i<=N+1;i++){ D[i] = q + A[i]; vi[i] = qi; vj[i] = qj; q += B[i]; if (q < p + C[i]){ q = p + C[i]; qi = pi; qj = i; } if (q < D[i-1] + C[i]){ q = D[i-1] + C[i]; qi = i - 1; qj = i; } p += B[i]; if (p < D[i-1] + B[i]){ p = D[i-1] + B[i]; pi = i-1; } } printf ("%lld\n",D[N+1]); int x = vi[N+1]; while (x){ printf ("%d ",x); x = vi[x]; } x = N+1; while (x){ int i = vi[x], j = vj[x]; for (int k=x-1;k>j;k--) printf ("%d ",k); for (int k=i+1;k<j;k++) printf ("%d ",k); printf ("%d ",j); x = i; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

space.cpp: In function 'int main()':
space.cpp:10:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d",&N);
                 ^
space.cpp:11:67: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=1;i<=N;i++) scanf ("%lld %lld %lld",&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...