Submission #58738

#TimeUsernameProblemLanguageResultExecution timeMemory
58738leejseo오렌지 출하 (JOI16_ho_t1)C++98
70 / 100
49 ms46464 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lld; const lld UNDEF = 1LL << 60; const int MAXN = 2000; int N, M; lld K, A[MAXN+1], B[MAXN+1][MAXN+1], C[MAXN+1][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 init(){ for (int i=1; i<=N; i++){ C[i][i] = A[i]; B[i][i] = A[i]; for (int j=i+1; j<=N; j++) B[i][j] = max(B[i][j-1], A[j]); for (int j=i+1; j<=N; j++) C[i][j] = min(C[i][j-1], A[j]); } } void DP(){ D[0] = 0; for (int i=1; i<=N; i++){ D[i] = D[i-1]+K; for (int k=max(1, i-M+1); k<i; k++){ D[i] = min(D[i], D[k-1] + K + (i-k+1) * (B[k][i] - C[k][i])); } } printf("%lld\n", D[N]); } int main(){ input(); init(); DP(); }

Compilation message (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...