#include "mountains.h"
using namespace std;
int C[2010][2010];
vector<int>adj[2010];
int DDDP[1<<20];
int maximum_deevs(vector<int> y) {
int n=y.size();
for(int i=1;i<n;i++){
int uuu=i-1;
C[i][i-1]=C[i-1][i]=1;
for(int j=i-1;j--;) {
long long ht=y[j]-y[i],dt=i-j;
long long hb=y[uuu]-y[i],db=i-uuu;
if(ht*db>=hb*dt)
C[i][j]=C[j][i]=1,uuu=j;
}
}
int ans=0;
int sz1=n/2,sz2=n-sz1;
for(int i=0;i<1<<sz2;i++){
vector<int>v;
for(int j=0;j<sz2;j++) if(i&1<<j)
v.push_back(sz1+j),DDDP[i]=max(DDDP[i],DDDP[i^1<<j]);
int bad=0;
for(auto A:v)
for(auto B:v)
if(C[A][B])
bad=1;
if(!bad)DDDP[i]=v.size();
}
for(int i=0;i<1<<sz1;i++){
int K2=1<<sz2;
int todo=0,bad=0;
K2--;
vector<int>v;
for(int j=0;j<sz1;j++)
if(i&1<<j)
v.push_back(j);
for(auto A:v)
for(auto B:v)
if(C[A][B])
bad=1;
if(!bad){
for(auto A:v)
for(int i=sz1;i<n;i++)
if(C[A][i])
todo|=1<<i-sz1;
ans=max(ans,DDDP[K2^todo]+(int)v.size());
}
}
return ans;
}
Compilation message
mountains.cpp: In function 'int maximum_deevs(std::vector<int>)':
mountains.cpp:47:35: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
47 | todo|=1<<i-sz1;
| ~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2464 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2464 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
472 ms |
5520 KB |
Output is correct |
18 |
Correct |
489 ms |
5460 KB |
Output is correct |
19 |
Correct |
467 ms |
5464 KB |
Output is correct |
20 |
Correct |
469 ms |
5320 KB |
Output is correct |
21 |
Correct |
455 ms |
5468 KB |
Output is correct |
22 |
Correct |
502 ms |
5368 KB |
Output is correct |
23 |
Correct |
458 ms |
5412 KB |
Output is correct |
24 |
Correct |
452 ms |
5456 KB |
Output is correct |
25 |
Correct |
461 ms |
5284 KB |
Output is correct |
26 |
Correct |
473 ms |
5524 KB |
Output is correct |
27 |
Correct |
472 ms |
5460 KB |
Output is correct |
28 |
Correct |
496 ms |
5716 KB |
Output is correct |
29 |
Correct |
459 ms |
5456 KB |
Output is correct |
30 |
Correct |
455 ms |
5412 KB |
Output is correct |
31 |
Correct |
466 ms |
5448 KB |
Output is correct |
32 |
Correct |
462 ms |
5332 KB |
Output is correct |
33 |
Correct |
373 ms |
5280 KB |
Output is correct |
34 |
Correct |
495 ms |
5420 KB |
Output is correct |
35 |
Correct |
523 ms |
5524 KB |
Output is correct |
36 |
Correct |
524 ms |
5456 KB |
Output is correct |
37 |
Correct |
476 ms |
5460 KB |
Output is correct |
38 |
Correct |
490 ms |
5460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2464 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
472 ms |
5520 KB |
Output is correct |
18 |
Correct |
489 ms |
5460 KB |
Output is correct |
19 |
Correct |
467 ms |
5464 KB |
Output is correct |
20 |
Correct |
469 ms |
5320 KB |
Output is correct |
21 |
Correct |
455 ms |
5468 KB |
Output is correct |
22 |
Correct |
502 ms |
5368 KB |
Output is correct |
23 |
Correct |
458 ms |
5412 KB |
Output is correct |
24 |
Correct |
452 ms |
5456 KB |
Output is correct |
25 |
Correct |
461 ms |
5284 KB |
Output is correct |
26 |
Correct |
473 ms |
5524 KB |
Output is correct |
27 |
Correct |
472 ms |
5460 KB |
Output is correct |
28 |
Correct |
496 ms |
5716 KB |
Output is correct |
29 |
Correct |
459 ms |
5456 KB |
Output is correct |
30 |
Correct |
455 ms |
5412 KB |
Output is correct |
31 |
Correct |
466 ms |
5448 KB |
Output is correct |
32 |
Correct |
462 ms |
5332 KB |
Output is correct |
33 |
Correct |
373 ms |
5280 KB |
Output is correct |
34 |
Correct |
495 ms |
5420 KB |
Output is correct |
35 |
Correct |
523 ms |
5524 KB |
Output is correct |
36 |
Correct |
524 ms |
5456 KB |
Output is correct |
37 |
Correct |
476 ms |
5460 KB |
Output is correct |
38 |
Correct |
490 ms |
5460 KB |
Output is correct |
39 |
Runtime error |
5 ms |
8600 KB |
Execution killed with signal 11 |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2464 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
472 ms |
5520 KB |
Output is correct |
18 |
Correct |
489 ms |
5460 KB |
Output is correct |
19 |
Correct |
467 ms |
5464 KB |
Output is correct |
20 |
Correct |
469 ms |
5320 KB |
Output is correct |
21 |
Correct |
455 ms |
5468 KB |
Output is correct |
22 |
Correct |
502 ms |
5368 KB |
Output is correct |
23 |
Correct |
458 ms |
5412 KB |
Output is correct |
24 |
Correct |
452 ms |
5456 KB |
Output is correct |
25 |
Correct |
461 ms |
5284 KB |
Output is correct |
26 |
Correct |
473 ms |
5524 KB |
Output is correct |
27 |
Correct |
472 ms |
5460 KB |
Output is correct |
28 |
Correct |
496 ms |
5716 KB |
Output is correct |
29 |
Correct |
459 ms |
5456 KB |
Output is correct |
30 |
Correct |
455 ms |
5412 KB |
Output is correct |
31 |
Correct |
466 ms |
5448 KB |
Output is correct |
32 |
Correct |
462 ms |
5332 KB |
Output is correct |
33 |
Correct |
373 ms |
5280 KB |
Output is correct |
34 |
Correct |
495 ms |
5420 KB |
Output is correct |
35 |
Correct |
523 ms |
5524 KB |
Output is correct |
36 |
Correct |
524 ms |
5456 KB |
Output is correct |
37 |
Correct |
476 ms |
5460 KB |
Output is correct |
38 |
Correct |
490 ms |
5460 KB |
Output is correct |
39 |
Runtime error |
5 ms |
8600 KB |
Execution killed with signal 11 |
40 |
Halted |
0 ms |
0 KB |
- |