#include<bits/stdc++.h>
#include "mountains.h"
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define FOR(i,N) for(i=0;i<(N);++i)
#define FORe(i,N) for(i=1;i<=(N);++i)
#define FORr(i,a,b) for(i=(a);i<(b);++i)
#define FORrev(i,N) for(i=(N);i>=0;--i)
#define F0R(i,N) for(int i=0;i<(N);++i)
#define F0Re(i,N) for(int i=1;i<=(N);++i)
#define F0Rr(i,a,b) for(ll i=(a);i<(b);++i)
#define F0Rrev(i,N) for(int i=(N);i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define dbgLine cerr<<" LINE : "<<__LINE__<<"\n"
#define ldd long double
using namespace std;
/*
const int Alp = 26;
const int __PRECISION = 9;
const int inf = 1e9 + 8;
const ldd PI = acos(-1);
const ldd EPS = 1e-7;
const ll MOD = 1e9 + 7;
const ll MAXN = 2e5 + 5;
const ll ROOTN = 320;
const ll LOGN = 18;
const ll INF = 1e18 + 1022;
*/
bool cross(pll a, pll b, pll c) {return 1LL*(a.ff - b.ff)*(b.ss - c.ss) >= 1LL*(a.ss - b.ss)*(b.ff - c.ff);}
int maximum_deevs(vector<int> y)
{
int ls, i, j, res, n = y.size();
vector<vi> dp(2020, vi(2020));
FOR(i, n)
{
dp[i][i] = dp[i][i+1] = 1;
ls = i-1;
res = 0;
FORrev(j, i-2)
{
if(cross(mp(j,y[j]), mp(ls,y[ls]), mp(i, y[i])))
{
res += dp[j+1][ls-1];
ls = j;
}
dp[j][i] = max(dp[j][i-1], 1 + res + dp[j][ls - 1]);
}
}
return dp[0][n-1];
}
/*
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout<<cross(mp(1,4), mp(2,2), mp(3,1))<<'\n';
int test_case_number;
cin>>test_case_number;
vi y; int j;
while(test_case_number--)
cin>>j, y.pb(j);
cout<<maximum_deevs(y)<<'\n';
return 0;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
16384 KB |
Output is correct |
2 |
Correct |
10 ms |
16384 KB |
Output is correct |
3 |
Correct |
13 ms |
16372 KB |
Output is correct |
4 |
Correct |
11 ms |
16384 KB |
Output is correct |
5 |
Correct |
14 ms |
16384 KB |
Output is correct |
6 |
Correct |
11 ms |
16384 KB |
Output is correct |
7 |
Correct |
10 ms |
16384 KB |
Output is correct |
8 |
Correct |
10 ms |
16384 KB |
Output is correct |
9 |
Correct |
10 ms |
16384 KB |
Output is correct |
10 |
Correct |
13 ms |
16384 KB |
Output is correct |
11 |
Correct |
11 ms |
16360 KB |
Output is correct |
12 |
Correct |
10 ms |
16384 KB |
Output is correct |
13 |
Correct |
11 ms |
16384 KB |
Output is correct |
14 |
Correct |
11 ms |
16384 KB |
Output is correct |
15 |
Correct |
11 ms |
16384 KB |
Output is correct |
16 |
Correct |
10 ms |
16384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
16384 KB |
Output is correct |
2 |
Correct |
10 ms |
16384 KB |
Output is correct |
3 |
Correct |
13 ms |
16372 KB |
Output is correct |
4 |
Correct |
11 ms |
16384 KB |
Output is correct |
5 |
Correct |
14 ms |
16384 KB |
Output is correct |
6 |
Correct |
11 ms |
16384 KB |
Output is correct |
7 |
Correct |
10 ms |
16384 KB |
Output is correct |
8 |
Correct |
10 ms |
16384 KB |
Output is correct |
9 |
Correct |
10 ms |
16384 KB |
Output is correct |
10 |
Correct |
13 ms |
16384 KB |
Output is correct |
11 |
Correct |
11 ms |
16360 KB |
Output is correct |
12 |
Correct |
10 ms |
16384 KB |
Output is correct |
13 |
Correct |
11 ms |
16384 KB |
Output is correct |
14 |
Correct |
11 ms |
16384 KB |
Output is correct |
15 |
Correct |
11 ms |
16384 KB |
Output is correct |
16 |
Correct |
10 ms |
16384 KB |
Output is correct |
17 |
Correct |
11 ms |
16384 KB |
Output is correct |
18 |
Correct |
10 ms |
16384 KB |
Output is correct |
19 |
Correct |
12 ms |
16332 KB |
Output is correct |
20 |
Correct |
11 ms |
16384 KB |
Output is correct |
21 |
Correct |
10 ms |
16384 KB |
Output is correct |
22 |
Correct |
12 ms |
16384 KB |
Output is correct |
23 |
Correct |
15 ms |
16384 KB |
Output is correct |
24 |
Correct |
10 ms |
16384 KB |
Output is correct |
25 |
Correct |
12 ms |
16384 KB |
Output is correct |
26 |
Correct |
13 ms |
16384 KB |
Output is correct |
27 |
Correct |
11 ms |
16384 KB |
Output is correct |
28 |
Correct |
11 ms |
16384 KB |
Output is correct |
29 |
Correct |
11 ms |
16384 KB |
Output is correct |
30 |
Correct |
13 ms |
16384 KB |
Output is correct |
31 |
Correct |
10 ms |
16384 KB |
Output is correct |
32 |
Correct |
12 ms |
16384 KB |
Output is correct |
33 |
Correct |
13 ms |
16384 KB |
Output is correct |
34 |
Correct |
14 ms |
16384 KB |
Output is correct |
35 |
Correct |
11 ms |
16384 KB |
Output is correct |
36 |
Correct |
10 ms |
16384 KB |
Output is correct |
37 |
Correct |
10 ms |
16384 KB |
Output is correct |
38 |
Correct |
12 ms |
16384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
16384 KB |
Output is correct |
2 |
Correct |
10 ms |
16384 KB |
Output is correct |
3 |
Correct |
13 ms |
16372 KB |
Output is correct |
4 |
Correct |
11 ms |
16384 KB |
Output is correct |
5 |
Correct |
14 ms |
16384 KB |
Output is correct |
6 |
Correct |
11 ms |
16384 KB |
Output is correct |
7 |
Correct |
10 ms |
16384 KB |
Output is correct |
8 |
Correct |
10 ms |
16384 KB |
Output is correct |
9 |
Correct |
10 ms |
16384 KB |
Output is correct |
10 |
Correct |
13 ms |
16384 KB |
Output is correct |
11 |
Correct |
11 ms |
16360 KB |
Output is correct |
12 |
Correct |
10 ms |
16384 KB |
Output is correct |
13 |
Correct |
11 ms |
16384 KB |
Output is correct |
14 |
Correct |
11 ms |
16384 KB |
Output is correct |
15 |
Correct |
11 ms |
16384 KB |
Output is correct |
16 |
Correct |
10 ms |
16384 KB |
Output is correct |
17 |
Correct |
11 ms |
16384 KB |
Output is correct |
18 |
Correct |
10 ms |
16384 KB |
Output is correct |
19 |
Correct |
12 ms |
16332 KB |
Output is correct |
20 |
Correct |
11 ms |
16384 KB |
Output is correct |
21 |
Correct |
10 ms |
16384 KB |
Output is correct |
22 |
Correct |
12 ms |
16384 KB |
Output is correct |
23 |
Correct |
15 ms |
16384 KB |
Output is correct |
24 |
Correct |
10 ms |
16384 KB |
Output is correct |
25 |
Correct |
12 ms |
16384 KB |
Output is correct |
26 |
Correct |
13 ms |
16384 KB |
Output is correct |
27 |
Correct |
11 ms |
16384 KB |
Output is correct |
28 |
Correct |
11 ms |
16384 KB |
Output is correct |
29 |
Correct |
11 ms |
16384 KB |
Output is correct |
30 |
Correct |
13 ms |
16384 KB |
Output is correct |
31 |
Correct |
10 ms |
16384 KB |
Output is correct |
32 |
Correct |
12 ms |
16384 KB |
Output is correct |
33 |
Correct |
13 ms |
16384 KB |
Output is correct |
34 |
Correct |
14 ms |
16384 KB |
Output is correct |
35 |
Correct |
11 ms |
16384 KB |
Output is correct |
36 |
Correct |
10 ms |
16384 KB |
Output is correct |
37 |
Correct |
10 ms |
16384 KB |
Output is correct |
38 |
Correct |
12 ms |
16384 KB |
Output is correct |
39 |
Correct |
13 ms |
16384 KB |
Output is correct |
40 |
Correct |
13 ms |
16384 KB |
Output is correct |
41 |
Correct |
11 ms |
16512 KB |
Output is correct |
42 |
Correct |
13 ms |
16384 KB |
Output is correct |
43 |
Correct |
13 ms |
16384 KB |
Output is correct |
44 |
Correct |
14 ms |
16352 KB |
Output is correct |
45 |
Correct |
12 ms |
16384 KB |
Output is correct |
46 |
Correct |
13 ms |
16384 KB |
Output is correct |
47 |
Correct |
14 ms |
16432 KB |
Output is correct |
48 |
Correct |
15 ms |
16384 KB |
Output is correct |
49 |
Correct |
13 ms |
16384 KB |
Output is correct |
50 |
Correct |
13 ms |
16384 KB |
Output is correct |
51 |
Correct |
13 ms |
16360 KB |
Output is correct |
52 |
Correct |
16 ms |
16384 KB |
Output is correct |
53 |
Correct |
15 ms |
16384 KB |
Output is correct |
54 |
Correct |
14 ms |
16384 KB |
Output is correct |
55 |
Correct |
13 ms |
16384 KB |
Output is correct |
56 |
Correct |
11 ms |
16384 KB |
Output is correct |
57 |
Correct |
11 ms |
16384 KB |
Output is correct |
58 |
Correct |
13 ms |
16416 KB |
Output is correct |
59 |
Correct |
10 ms |
16416 KB |
Output is correct |
60 |
Correct |
11 ms |
16384 KB |
Output is correct |
61 |
Correct |
10 ms |
16384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
16384 KB |
Output is correct |
2 |
Correct |
10 ms |
16384 KB |
Output is correct |
3 |
Correct |
13 ms |
16372 KB |
Output is correct |
4 |
Correct |
11 ms |
16384 KB |
Output is correct |
5 |
Correct |
14 ms |
16384 KB |
Output is correct |
6 |
Correct |
11 ms |
16384 KB |
Output is correct |
7 |
Correct |
10 ms |
16384 KB |
Output is correct |
8 |
Correct |
10 ms |
16384 KB |
Output is correct |
9 |
Correct |
10 ms |
16384 KB |
Output is correct |
10 |
Correct |
13 ms |
16384 KB |
Output is correct |
11 |
Correct |
11 ms |
16360 KB |
Output is correct |
12 |
Correct |
10 ms |
16384 KB |
Output is correct |
13 |
Correct |
11 ms |
16384 KB |
Output is correct |
14 |
Correct |
11 ms |
16384 KB |
Output is correct |
15 |
Correct |
11 ms |
16384 KB |
Output is correct |
16 |
Correct |
10 ms |
16384 KB |
Output is correct |
17 |
Correct |
11 ms |
16384 KB |
Output is correct |
18 |
Correct |
10 ms |
16384 KB |
Output is correct |
19 |
Correct |
12 ms |
16332 KB |
Output is correct |
20 |
Correct |
11 ms |
16384 KB |
Output is correct |
21 |
Correct |
10 ms |
16384 KB |
Output is correct |
22 |
Correct |
12 ms |
16384 KB |
Output is correct |
23 |
Correct |
15 ms |
16384 KB |
Output is correct |
24 |
Correct |
10 ms |
16384 KB |
Output is correct |
25 |
Correct |
12 ms |
16384 KB |
Output is correct |
26 |
Correct |
13 ms |
16384 KB |
Output is correct |
27 |
Correct |
11 ms |
16384 KB |
Output is correct |
28 |
Correct |
11 ms |
16384 KB |
Output is correct |
29 |
Correct |
11 ms |
16384 KB |
Output is correct |
30 |
Correct |
13 ms |
16384 KB |
Output is correct |
31 |
Correct |
10 ms |
16384 KB |
Output is correct |
32 |
Correct |
12 ms |
16384 KB |
Output is correct |
33 |
Correct |
13 ms |
16384 KB |
Output is correct |
34 |
Correct |
14 ms |
16384 KB |
Output is correct |
35 |
Correct |
11 ms |
16384 KB |
Output is correct |
36 |
Correct |
10 ms |
16384 KB |
Output is correct |
37 |
Correct |
10 ms |
16384 KB |
Output is correct |
38 |
Correct |
12 ms |
16384 KB |
Output is correct |
39 |
Correct |
13 ms |
16384 KB |
Output is correct |
40 |
Correct |
13 ms |
16384 KB |
Output is correct |
41 |
Correct |
11 ms |
16512 KB |
Output is correct |
42 |
Correct |
13 ms |
16384 KB |
Output is correct |
43 |
Correct |
13 ms |
16384 KB |
Output is correct |
44 |
Correct |
14 ms |
16352 KB |
Output is correct |
45 |
Correct |
12 ms |
16384 KB |
Output is correct |
46 |
Correct |
13 ms |
16384 KB |
Output is correct |
47 |
Correct |
14 ms |
16432 KB |
Output is correct |
48 |
Correct |
15 ms |
16384 KB |
Output is correct |
49 |
Correct |
13 ms |
16384 KB |
Output is correct |
50 |
Correct |
13 ms |
16384 KB |
Output is correct |
51 |
Correct |
13 ms |
16360 KB |
Output is correct |
52 |
Correct |
16 ms |
16384 KB |
Output is correct |
53 |
Correct |
15 ms |
16384 KB |
Output is correct |
54 |
Correct |
14 ms |
16384 KB |
Output is correct |
55 |
Correct |
13 ms |
16384 KB |
Output is correct |
56 |
Correct |
11 ms |
16384 KB |
Output is correct |
57 |
Correct |
11 ms |
16384 KB |
Output is correct |
58 |
Correct |
13 ms |
16416 KB |
Output is correct |
59 |
Correct |
10 ms |
16416 KB |
Output is correct |
60 |
Correct |
11 ms |
16384 KB |
Output is correct |
61 |
Correct |
10 ms |
16384 KB |
Output is correct |
62 |
Correct |
13 ms |
16384 KB |
Output is correct |
63 |
Correct |
31 ms |
16456 KB |
Output is correct |
64 |
Correct |
33 ms |
16384 KB |
Output is correct |
65 |
Correct |
36 ms |
16384 KB |
Output is correct |
66 |
Correct |
33 ms |
16404 KB |
Output is correct |
67 |
Correct |
29 ms |
16384 KB |
Output is correct |
68 |
Correct |
35 ms |
16384 KB |
Output is correct |
69 |
Correct |
34 ms |
16416 KB |
Output is correct |
70 |
Correct |
35 ms |
16436 KB |
Output is correct |
71 |
Correct |
42 ms |
16376 KB |
Output is correct |
72 |
Correct |
39 ms |
16384 KB |
Output is correct |
73 |
Correct |
36 ms |
16384 KB |
Output is correct |
74 |
Correct |
43 ms |
16384 KB |
Output is correct |
75 |
Correct |
46 ms |
16364 KB |
Output is correct |
76 |
Correct |
44 ms |
16440 KB |
Output is correct |
77 |
Correct |
43 ms |
16384 KB |
Output is correct |
78 |
Correct |
54 ms |
16376 KB |
Output is correct |
79 |
Correct |
52 ms |
16384 KB |
Output is correct |
80 |
Correct |
55 ms |
16416 KB |
Output is correct |
81 |
Correct |
47 ms |
16384 KB |
Output is correct |
82 |
Correct |
40 ms |
16384 KB |
Output is correct |
83 |
Correct |
39 ms |
16384 KB |
Output is correct |
84 |
Correct |
38 ms |
16384 KB |
Output is correct |
85 |
Correct |
42 ms |
16384 KB |
Output is correct |
86 |
Correct |
35 ms |
16424 KB |
Output is correct |