제출 #117156

#제출 시각아이디문제언어결과실행 시간메모리
117156onjo0127오렌지 출하 (JOI16_ho_t1)C++11
100 / 100
42 ms780 KiB
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int A[20009]; long long D[20009]; int main() { int N, M, K; 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++) { int mx = -INF, mn = INF; D[i] = 1LL * 1e18; for(int j=i-1; j>=max(0, i-M); j--) { mx = max(mx, A[j+1]); mn = min(mn, A[j+1]); D[i] = min(D[i], D[j] + K + 1LL * (i-j) * (mx-mn)); } } printf("%lld", D[N]); return 0; }

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

2016_ho_t1.cpp: In function 'int main()':
2016_ho_t1.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int N, M, K; scanf("%d%d%d",&N,&M,&K);
                  ~~~~~^~~~~~~~~~~~~~~~~~~
2016_ho_t1.cpp:10: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...