Submission #411702

# Submission time Handle Problem Language Result Execution time Memory
411702 2021-05-25T18:31:14 Z nxteru Mountains (IOI17_mountains) C++14
20 / 100
1000 ms 296 KB
#include "mountains.h"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
vector<int>y;
int solve(int l,int r){
	if(r<l)return 0;
	if(l==r)return 1;
	int ma=-1;
	for(int i=l;i<=r;i++){
		if(ma==-1||y[ma]<y[i])ma=i;
	}
	int s=1;
	int la=ma;
	for(int i=ma-1;i>=l;i--){
		if(ll(y[ma]-y[i])*ll(ma-la)<=ll(y[ma]-y[la])*ll(ma-i)){
			s+=solve(i+1,la-1);
			la=i;
		}
	}
	s+=solve(l,la-1);
	la=ma;
	for(int i=ma+1;i<=r;i++){
		if(ll(y[ma]-y[i])*ll(ma-la)>=ll(y[ma]-y[la])*ll(ma-i)){
			s+=solve(la+1,i-1);
			la=i;
		}
	}
	s+=solve(la+1,r);
	return max(s,solve(l,ma-1)+solve(ma+1,r));
}
int maximum_deevs(vector<int> Y) {
	y=Y;
	return solve(0,y.size()-1);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 296 KB Output is correct
28 Correct 2 ms 204 KB Output is correct
29 Correct 2 ms 204 KB Output is correct
30 Correct 2 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 2 ms 204 KB Output is correct
33 Execution timed out 1089 ms 204 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 296 KB Output is correct
28 Correct 2 ms 204 KB Output is correct
29 Correct 2 ms 204 KB Output is correct
30 Correct 2 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 2 ms 204 KB Output is correct
33 Execution timed out 1089 ms 204 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 296 KB Output is correct
28 Correct 2 ms 204 KB Output is correct
29 Correct 2 ms 204 KB Output is correct
30 Correct 2 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 2 ms 204 KB Output is correct
33 Execution timed out 1089 ms 204 KB Time limit exceeded
34 Halted 0 ms 0 KB -