제출 #906285

#제출 시각아이디문제언어결과실행 시간메모리
906285AlphaMale06오렌지 출하 (JOI16_ho_t1)C++14
100 / 100
36 ms960 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define yes cout << "YES\n" #define no cout << "NO\n" #define F first #define S second #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define int long long void solve(){ int n, m, k; cin >> n >> m >> k; int a[n]; int dp[n+1]={0}; for(int i=0; i< n; i++)cin >> a[i]; for(int i=1; i<=n; i++){ dp[i]=2e18; int mx=a[i-1]; int mn=a[i-1]; for(int j=i; j>=max(1ll, i-m+1); j--){ mx=max(mx, a[j-1]); mn=min(mn, a[j-1]); dp[i]=min(dp[i], k+dp[j-1]+(mx-mn)*(i-j+1)); } } cout << dp[n] << '\n'; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...