제출 #58739

#제출 시각아이디문제언어결과실행 시간메모리
58739leejseo오렌지 출하 (JOI16_ho_t1)C++98
100 / 100
85 ms3600 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lld; const lld UNDEF = 1LL << 60; const int MAXN = 20000; int N, M; lld K, A[MAXN+1], D[MAXN+1]; void input(){ scanf("%d%d%lld", &N, &M, &K); for (int i=0; i<N; i++) scanf("%lld", &A[i+1]); } void DP(){ D[0] = 0; for (int i=1; i<=N; i++){ D[i] = D[i-1]+K; lld m1 = A[i], m2 = A[i]; for (int k=i-1; k > max(0,i-M); k--){ m1 = max(m1, A[k]), m2 = min(m2, A[k]); D[i] = min(D[i], D[k-1] + K + (i-k+1) * (m1 - m2)); } } printf("%lld\n", D[N]); } int main(){ input(); DP(); }

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

2016_ho_t1.cpp: In function 'void input()':
2016_ho_t1.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%lld", &N, &M, &K);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
2016_ho_t1.cpp:11:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i=0; i<N; i++) scanf("%lld", &A[i+1]);
                             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...