Submission #1207892

#TimeUsernameProblemLanguageResultExecution timeMemory
1207892PlayVoltz오렌지 출하 (JOI16_ho_t1)C++20
100 / 100
28 ms760 KiB
#include <cstdio> #include <stdio.h> #include <stdbool.h> #include <iostream> #include <map> #include <vector> #include <climits> #include <stack> #include <string> #include <queue> #include <algorithm> #include <set> #include <unordered_set> #include <unordered_map> #include <cmath> #include <cctype> #include <bitset> #include <iomanip> #include <cstring> #include <numeric> #include <cassert> #include <chrono> using namespace std; #define int long long #define pii pair<int, int> #define mp make_pair #define pb push_back #define fi first #define se second int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; cin>>n>>m>>k; vector<int> vect(n+1), dp(n+1, LLONG_MAX/2); dp[0]=0; for (int i=1; i<=n; ++i){ cin>>vect[i]; for (int j=i, mx=vect[i], mn=vect[i]; j>=max(i-m+1, 1ll); --j){ mx=max(mx, vect[j]); mn=min(mn, vect[j]); dp[i]=min(dp[i], k+(i-j+1)*(mx-mn)+dp[j-1]); } } cout<<dp[n]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...