Submission #146748

#TimeUsernameProblemLanguageResultExecution timeMemory
146748TadijaSebez오렌지 출하 (JOI16_ho_t1)C++11
100 / 100
67 ms888 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N=20050; const ll inf=9e18; void ckmn(ll &a, ll b){ a=min(a,b);} void ckmn(int &a, int b){ a=min(a,b);} void ckmx(int &a, int b){ a=max(a,b);} int a[N]; ll dp[N]; int main() { int n,m,k; scanf("%i %i %i",&n,&m,&k); for(int i=1;i<=n;i++) { scanf("%i",&a[i]); int mx=a[i],mn=a[i]; dp[i]=inf; for(int j=i;j>=1 && i-j+1<=m;j--) { ckmn(mn,a[j]); ckmx(mx,a[j]); ckmn(dp[i],dp[j-1]+k+(ll)(i-j+1)*(mx-mn)); } } printf("%lld\n",dp[n]); return 0; }

Compilation message (stderr)

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