제출 #70465

#제출 시각아이디문제언어결과실행 시간메모리
70465Diuven오렌지 출하 (JOI16_ho_t1)C++14
100 / 100
139 ms5616 KiB
#include <cstdio> typedef long long ll; const int inf=2e9; const ll linf=2e18; ll min(ll a, ll b){ return a<b ? a : b; } ll max(ll a, ll b){ return a>b ? a : b; } int n, m, k, A[20010]; ll D[20010]; ll d(int i){ if(D[i]>=0) return D[i]; D[i]=linf; for(int s=1, a=-inf, b=inf; s<=m; s++){ if(i<s) break; a=max(a, A[i-s+1]), b=min(b, A[i-s+1]); D[i]=min(D[i], d(i-s)+k+s*ll(a-b)); } return D[i]; } int main(){ scanf("%d%d%d", &n, &m, &k); for(int i=1; i<=n; i++) scanf("%d", A+i); for(int i=1; i<=n; i++) D[i]=-1; D[0]=0; printf("%lld\n", d(n)); return 0; }

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

2016_ho_t1.cpp: In function 'int main()':
2016_ho_t1.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
2016_ho_t1.cpp:25:34: 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("%d", A+i);
                             ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...