제출 #5150

#제출 시각아이디문제언어결과실행 시간메모리
5150tncks0121K blocks (IZhO14_blocks)C++98
53 / 100
1000 ms2260 KiB
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <math.h> #include <assert.h> #include <stack> #include <queue> #include <map> #include <set> #include <algorithm> #include <string> #include <functional> #include <vector> #include <deque> #include <utility> #include <bitset> #include <limits.h> #include <time.h> using namespace std; typedef long long ll; typedef unsigned long long llu; typedef double lf; typedef unsigned int uint; typedef long double llf; typedef pair<int, int> pii; const int N_ = 100005; int N, K; int A[N_]; int Table[2][N_]; int main() { scanf("%d%d", &N, &K); for(int i = 1; i <= N; i++) scanf("%d", A+i); for(int i = 1; i <= N; i++) Table[0][i] = (int)1e9; for(int k = 1; k <= K; k++) { int *now = Table[k&1], *prev = Table[~k&1]; for(int i = 0; i <= N; i++) now[i] = (int)1e9; for(int i = k; i <= N; i++) { int mx = 0; for(int j = i; j >= k-1; j--) { mx = max(mx, A[j]); now[i] = min(now[i], prev[j - 1] + mx); } } } printf("%d\n", Table[K&1][N]); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...