Submission #502140

# Submission time Handle Problem Language Result Execution time Memory
502140 2022-01-05T10:58:00 Z EliteCallsYou K blocks (IZhO14_blocks) C++17
32 / 100
1000 ms 296 KB
# include <bits/stdc++.h>
using namespace std ;
//############################################################################
# define read(a)/**/for(int i=0;i<int(sizeof(a)/sizeof(a[0]));i++){cin>>a[i];}
# define print(x)/**/for(auto zx:x){cout<<zx<<' ';}
const char* tochar(string a){return a.c_str();}
void files(){freopen("planting.in","r",stdin);freopen("planting.out","w",stdout);}
void speed(){ios_base::sync_with_stdio(false);cin.tie(0);}
long long gcd(long long a,long long b){if(!b){return a;}a%=b;return gcd(b,a);}
long long lcm(long long a,long long b){return a /gcd(a,b) * b;}
//###########################################################################
const int N = 1e5 + 5 ;
const long long MOD = 1e9+7 ;
//###########################################################################
void hack(){}
//###########################################################################

int n, m, mn = 1e9 ;
vector < int > vc ;
int ar[10005] ;

void rec( int pos, int k ){
	if ( !k ){
		vc.push_back(n-1) ;
		int cur = 0, sum = 0, pos = 0 ;

		for ( int i = 0 ; i < n ; i ++ ){
			cur = max(cur,ar[i]) ;
			if ( i == vc[pos] ){
				sum += cur ;
				cur = 0 ;	
				pos ++ ;
			}
		}

		mn = min(mn,sum) ;
		vc.pop_back() ;
		return ;
	}
	for ( int i = pos ; i < n-1 ; i ++ ){
		vc.push_back(i) ;
		rec(i+1,k-1) ;
		vc.pop_back() ;
	} 
}

int main(){
	cin >> n >> m ;
	for ( int i = 0 ; i < n ; i ++ ){
		cin >> ar[i] ;
	}
	rec(0,m-1) ;
	cout << mn << '\n' ;
}

Compilation message

blocks.cpp: In function 'void files()':
blocks.cpp:7:21: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | void files(){freopen("planting.in","r",stdin);freopen("planting.out","w",stdout);}
      |              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
blocks.cpp:7:54: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | void files(){freopen("planting.in","r",stdin);freopen("planting.out","w",stdout);}
      |                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 292 KB Output is correct
13 Correct 612 ms 280 KB Output is correct
14 Correct 597 ms 276 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 572 ms 284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 292 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 292 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 296 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 7 ms 204 KB Output is correct
15 Correct 6 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 4 ms 288 KB Output is correct
18 Correct 6 ms 204 KB Output is correct
19 Correct 4 ms 204 KB Output is correct
20 Correct 3 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 292 KB Output is correct
13 Correct 612 ms 280 KB Output is correct
14 Correct 597 ms 276 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 572 ms 284 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 292 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 292 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 296 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 7 ms 204 KB Output is correct
33 Correct 6 ms 204 KB Output is correct
34 Correct 4 ms 204 KB Output is correct
35 Correct 4 ms 288 KB Output is correct
36 Correct 6 ms 204 KB Output is correct
37 Correct 4 ms 204 KB Output is correct
38 Correct 3 ms 292 KB Output is correct
39 Execution timed out 1085 ms 204 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 292 KB Output is correct
13 Correct 612 ms 280 KB Output is correct
14 Correct 597 ms 276 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 572 ms 284 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 292 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 292 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 296 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 7 ms 204 KB Output is correct
33 Correct 6 ms 204 KB Output is correct
34 Correct 4 ms 204 KB Output is correct
35 Correct 4 ms 288 KB Output is correct
36 Correct 6 ms 204 KB Output is correct
37 Correct 4 ms 204 KB Output is correct
38 Correct 3 ms 292 KB Output is correct
39 Execution timed out 1085 ms 204 KB Time limit exceeded
40 Halted 0 ms 0 KB -