답안 #25521

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25521 2017-06-22T18:14:05 Z RezwanArefin01 K개의 묶음 (IZhO14_blocks) C++14
53 / 100
1000 ms 50072 KB
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 1e5 + 10;
int n, kk, arr[maxn], rmq[maxn][20], lg[maxn]; 
int dp[101][maxn]; 
int Max(int i, int j) {
	int l = lg[j-i+1]; 
	return max(rmq[i][l], rmq[j - (1 << l) + 1][l]);
}
int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
	freopen("in", "r", stdin);
#endif

	cin>>n>>kk;
	for(int i=1; i<=n; i++) {
		cin>>arr[i]; 
		rmq[i][0] = arr[i];
	} lg[1] = 0;
	for(int i = 2; i <= n; i++) 
		lg[i] = lg[i>>1] + 1;

	for(int i = 1; i<=20; i++)
		for(int j=1; j <= n; j++) 
			if(j + (1 << (i-1)) <= n) 
				rmq[j][i] = max(rmq[j][i-1], rmq[j + (1 << (i-1))][i-1]); 

	memset(dp, 0x3f, sizeof dp); 

	for(int i=1; i<=n; i++) 
		dp[1][i] = Max(1, i); 

	for(int k=2; k <= kk; k++) {
		for(int i=1; i <= n; i++) {
			for(int j = 1; j < i; j++) 
				dp[k][i] = min(dp[k][i], dp[k-1][j] + Max(j+1, i)); 
		}		
	} cout<<dp[kk][n]<<endl;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 50072 KB Output is correct
2 Correct 6 ms 50072 KB Output is correct
3 Correct 0 ms 50072 KB Output is correct
4 Correct 3 ms 50072 KB Output is correct
5 Correct 0 ms 50072 KB Output is correct
6 Correct 3 ms 50072 KB Output is correct
7 Correct 0 ms 50072 KB Output is correct
8 Correct 0 ms 50072 KB Output is correct
9 Correct 3 ms 50072 KB Output is correct
10 Correct 0 ms 50072 KB Output is correct
11 Correct 0 ms 50072 KB Output is correct
12 Correct 0 ms 50072 KB Output is correct
13 Correct 0 ms 50072 KB Output is correct
14 Correct 0 ms 50072 KB Output is correct
15 Correct 0 ms 50072 KB Output is correct
16 Correct 0 ms 50072 KB Output is correct
17 Correct 0 ms 50072 KB Output is correct
18 Correct 6 ms 50072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 50072 KB Output is correct
2 Correct 3 ms 50072 KB Output is correct
3 Correct 3 ms 50072 KB Output is correct
4 Correct 0 ms 50072 KB Output is correct
5 Correct 0 ms 50072 KB Output is correct
6 Correct 0 ms 50072 KB Output is correct
7 Correct 3 ms 50072 KB Output is correct
8 Correct 3 ms 50072 KB Output is correct
9 Correct 3 ms 50072 KB Output is correct
10 Correct 0 ms 50072 KB Output is correct
11 Correct 3 ms 50072 KB Output is correct
12 Correct 6 ms 50072 KB Output is correct
13 Correct 0 ms 50072 KB Output is correct
14 Correct 6 ms 50072 KB Output is correct
15 Correct 3 ms 50072 KB Output is correct
16 Correct 13 ms 50072 KB Output is correct
17 Correct 0 ms 50072 KB Output is correct
18 Correct 3 ms 50072 KB Output is correct
19 Correct 3 ms 50072 KB Output is correct
20 Correct 6 ms 50072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 50072 KB Output is correct
2 Correct 3 ms 50072 KB Output is correct
3 Correct 0 ms 50072 KB Output is correct
4 Correct 3 ms 50072 KB Output is correct
5 Correct 6 ms 50072 KB Output is correct
6 Correct 0 ms 50072 KB Output is correct
7 Correct 3 ms 50072 KB Output is correct
8 Correct 3 ms 50072 KB Output is correct
9 Correct 0 ms 50072 KB Output is correct
10 Correct 0 ms 50072 KB Output is correct
11 Correct 3 ms 50072 KB Output is correct
12 Correct 0 ms 50072 KB Output is correct
13 Correct 0 ms 50072 KB Output is correct
14 Correct 6 ms 50072 KB Output is correct
15 Correct 3 ms 50072 KB Output is correct
16 Correct 3 ms 50072 KB Output is correct
17 Correct 0 ms 50072 KB Output is correct
18 Correct 6 ms 50072 KB Output is correct
19 Correct 3 ms 50072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 50072 KB Execution timed out
2 Halted 0 ms 0 KB -