제출 #287461

#제출 시각아이디문제언어결과실행 시간메모리
287461Namnamseo오렌지 출하 (JOI16_ho_t1)C++17
100 / 100
85 ms924 KiB
#include <cstdio> int n,m,k; int data[20010]; typedef long long ll; ll dp[20010]; template<typename T> inline T max(T a,T b){ return b<a?a:b; } template<typename T> inline T min(T a,T b){ return a<b?a:b; } int main() { scanf("%d%d%d",&n,&m,&k); int i,j; int Mx, mn; for(i=1;i<=n;++i){ scanf("%d",data+i); Mx=mn=data[i]; dp[i]=(1LL<<61); for(j=i;j && i-j<m;--j){ Mx=max(Mx,data[j]); mn=min(mn,data[j]); dp[i]=min(dp[i], dp[j-1]+k+ll(i-j+1)*(Mx-mn)); } } printf("%lld",dp[n]); return 0; }

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

2016_ho_t1.cpp: In function 'int main()':
2016_ho_t1.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |     scanf("%d%d%d",&n,&m,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
2016_ho_t1.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |         scanf("%d",data+i);
      |         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...