제출 #1129756

#제출 시각아이디문제언어결과실행 시간메모리
1129756assanaliK개의 묶음 (IZhO14_blocks)C++17
53 / 100
1035 ms628 KiB
#include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define F first #define S second #define pb push_back #define lv v+v #define rv v+v+1 using namespace std; using ll = long long; using ld = long double; using pll = pair <long long, long long>; using pii = pair <int,int>; using pld = pair <long double, long double>; #pragma GCC optimize("unroll-loops") #pragma GCC optimize("O3") long long mod = 1e9 + 7; const ll N = 1e5 + 10; const ll M = 1e2 + 10; const ll P = 311; const ld EPS = 1e-7; const ll block = 450; const ll inf = 1e18; ll n,a[N],k,ans,dp[N][M]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); ll _=1; //cin>>_; while(_--) { cin>>n>>k; for(ll i = 1; i<=n; i++) { cin>>a[i]; } ll mx = 0; for(ll i = 1; i<=n; i++) { for(ll j = 1; j<=k; j++) { dp[j][i] = INT_MAX; } } for(ll i = 1; i<=n; i++) { mx = max(mx, a[i]); dp[1][i] = mx; } for(ll c = 2; c<=k; c++) { for(ll i = c; i<=n; i++) { ll cur = 0; for(ll j = i; j<=n; j++) { cur = max(cur, a[j]); dp[c][j] = min(dp[c][j], cur + dp[c-1][i-1]); } } } cout<<dp[k][n]; } return 0; } // equal, min, max, 1, random, build /* 6 3 6 4 5 1 2 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...