제출 #221921

#제출 시각아이디문제언어결과실행 시간메모리
221921mhy908오렌지 출하 (JOI16_ho_t1)C++14
100 / 100
55 ms888 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n, m;
LL k, a[20010], dp[20010];
int main(){
    scanf("%d %d %lld", &n, &m, &k);
    for(int i=1; i<=n; i++)scanf("%lld", &a[i]);
    for(int i=1; i<=n; i++){
        LL maxx=a[i], minn=a[i];
        dp[i]=987654312987654321ll;
        for(int j=i; j>i-m&&j>0; j--){
            maxx=max(maxx, a[j]);
            minn=min(minn, a[j]);
            dp[i]=min(dp[i], dp[j-1]+k+(maxx-minn)*(i-j+1));
        }
    }
    printf("%lld", dp[n]);
}

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

2016_ho_t1.cpp: In function 'int main()':
2016_ho_t1.cpp:7: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:8:33: 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", &a[i]);
                            ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...