제출 #136940

#제출 시각아이디문제언어결과실행 시간메모리
136940ksmzzang2003오렌지 출하 (JOI16_ho_t1)C++14
100 / 100
78 ms1656 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll N,M,K,arr[20003],memo[20003]; ll f(ll n) { if(n<0) return 1LL<<61; if(n==0) return 0; if(memo[n]!=-1) return memo[n]; ll ret = 1LL<<60; ll maxv=-1,minv=1LL<<61; for(ll i=n; i>=n-M+1; i--) { maxv = max(maxv,arr[i]); minv= min(minv,arr[i]); ret = min(ret,f(i-1)+K+(n+1-i)*(maxv-minv)); } return memo[n] = ret; } int main() { fill(memo,memo+20003,-1); scanf("%lld %lld %lld",&N,&M,&K); for(ll i=1; i<=N; i++) scanf("%lld",&arr[i]); printf("%lld",f(N)); }

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

2016_ho_t1.cpp: In function 'int main()':
2016_ho_t1.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld %lld",&N,&M,&K);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
2016_ho_t1.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&arr[i]);
         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...