#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define pb push_back
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ii = pair<int,int>;
using iii = tuple<int,int,int>;
const int inf = 2e9+1;
const int mod = 1e9+7;
const int maxn = 1e5+100;
template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }
int dp[2001][2001], y[2001];
bool pode[2001][2001];
int maximum_deevs(vector<int>v){
int n = sz(v);
for(int i=0;i<n;++i){
y[i+1] = v[i];
ll bx = 0, by = 0;
for(int j=i+1;j<n;++j){
if(bx*ll(v[j]-v[i])<by*ll(j-i))pode[i+1][j+1] = 1;
else bx = ll(j-i), by = ll(v[j]-v[i]);
}
}
for(int r=1;r<=n;++r){
dp[r][r] = 1;
int sum = 0, last = r;
for(int l=r-1;l>=1;--l){
dp[l][r] = dp[l][r-1];
if(pode[l][r]==0){
sum += dp[l+1][last-1], last = l;
}
ckmax(dp[l][r], sum + 1 + dp[l][last-1]);
}
}
return dp[1][n];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
432 KB |
Output is correct |
19 |
Correct |
1 ms |
436 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
488 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
428 KB |
Output is correct |
34 |
Correct |
1 ms |
436 KB |
Output is correct |
35 |
Correct |
1 ms |
436 KB |
Output is correct |
36 |
Correct |
1 ms |
468 KB |
Output is correct |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
432 KB |
Output is correct |
19 |
Correct |
1 ms |
436 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
488 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
428 KB |
Output is correct |
34 |
Correct |
1 ms |
436 KB |
Output is correct |
35 |
Correct |
1 ms |
436 KB |
Output is correct |
36 |
Correct |
1 ms |
468 KB |
Output is correct |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Correct |
1 ms |
468 KB |
Output is correct |
39 |
Correct |
1 ms |
1492 KB |
Output is correct |
40 |
Correct |
1 ms |
2260 KB |
Output is correct |
41 |
Correct |
1 ms |
2260 KB |
Output is correct |
42 |
Correct |
2 ms |
2260 KB |
Output is correct |
43 |
Correct |
1 ms |
2260 KB |
Output is correct |
44 |
Correct |
1 ms |
2260 KB |
Output is correct |
45 |
Correct |
2 ms |
2280 KB |
Output is correct |
46 |
Correct |
1 ms |
2260 KB |
Output is correct |
47 |
Correct |
1 ms |
2260 KB |
Output is correct |
48 |
Correct |
2 ms |
2260 KB |
Output is correct |
49 |
Correct |
1 ms |
2228 KB |
Output is correct |
50 |
Correct |
2 ms |
2224 KB |
Output is correct |
51 |
Correct |
2 ms |
2260 KB |
Output is correct |
52 |
Correct |
2 ms |
2320 KB |
Output is correct |
53 |
Correct |
2 ms |
2260 KB |
Output is correct |
54 |
Correct |
2 ms |
2228 KB |
Output is correct |
55 |
Correct |
1 ms |
2260 KB |
Output is correct |
56 |
Correct |
2 ms |
2260 KB |
Output is correct |
57 |
Correct |
1 ms |
2260 KB |
Output is correct |
58 |
Correct |
2 ms |
2260 KB |
Output is correct |
59 |
Correct |
1 ms |
2228 KB |
Output is correct |
60 |
Correct |
1 ms |
2260 KB |
Output is correct |
61 |
Correct |
1 ms |
2260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
432 KB |
Output is correct |
19 |
Correct |
1 ms |
436 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
488 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
428 KB |
Output is correct |
34 |
Correct |
1 ms |
436 KB |
Output is correct |
35 |
Correct |
1 ms |
436 KB |
Output is correct |
36 |
Correct |
1 ms |
468 KB |
Output is correct |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Correct |
1 ms |
468 KB |
Output is correct |
39 |
Correct |
1 ms |
1492 KB |
Output is correct |
40 |
Correct |
1 ms |
2260 KB |
Output is correct |
41 |
Correct |
1 ms |
2260 KB |
Output is correct |
42 |
Correct |
2 ms |
2260 KB |
Output is correct |
43 |
Correct |
1 ms |
2260 KB |
Output is correct |
44 |
Correct |
1 ms |
2260 KB |
Output is correct |
45 |
Correct |
2 ms |
2280 KB |
Output is correct |
46 |
Correct |
1 ms |
2260 KB |
Output is correct |
47 |
Correct |
1 ms |
2260 KB |
Output is correct |
48 |
Correct |
2 ms |
2260 KB |
Output is correct |
49 |
Correct |
1 ms |
2228 KB |
Output is correct |
50 |
Correct |
2 ms |
2224 KB |
Output is correct |
51 |
Correct |
2 ms |
2260 KB |
Output is correct |
52 |
Correct |
2 ms |
2320 KB |
Output is correct |
53 |
Correct |
2 ms |
2260 KB |
Output is correct |
54 |
Correct |
2 ms |
2228 KB |
Output is correct |
55 |
Correct |
1 ms |
2260 KB |
Output is correct |
56 |
Correct |
2 ms |
2260 KB |
Output is correct |
57 |
Correct |
1 ms |
2260 KB |
Output is correct |
58 |
Correct |
2 ms |
2260 KB |
Output is correct |
59 |
Correct |
1 ms |
2228 KB |
Output is correct |
60 |
Correct |
1 ms |
2260 KB |
Output is correct |
61 |
Correct |
1 ms |
2260 KB |
Output is correct |
62 |
Correct |
7 ms |
8248 KB |
Output is correct |
63 |
Correct |
27 ms |
17976 KB |
Output is correct |
64 |
Correct |
29 ms |
17984 KB |
Output is correct |
65 |
Correct |
35 ms |
17944 KB |
Output is correct |
66 |
Correct |
28 ms |
18000 KB |
Output is correct |
67 |
Correct |
31 ms |
17996 KB |
Output is correct |
68 |
Correct |
30 ms |
17928 KB |
Output is correct |
69 |
Correct |
30 ms |
18100 KB |
Output is correct |
70 |
Correct |
34 ms |
17992 KB |
Output is correct |
71 |
Correct |
33 ms |
18020 KB |
Output is correct |
72 |
Correct |
34 ms |
17968 KB |
Output is correct |
73 |
Correct |
35 ms |
18012 KB |
Output is correct |
74 |
Correct |
34 ms |
17940 KB |
Output is correct |
75 |
Correct |
33 ms |
17868 KB |
Output is correct |
76 |
Correct |
28 ms |
17964 KB |
Output is correct |
77 |
Correct |
40 ms |
17952 KB |
Output is correct |
78 |
Correct |
40 ms |
17940 KB |
Output is correct |
79 |
Correct |
38 ms |
17996 KB |
Output is correct |
80 |
Correct |
37 ms |
17996 KB |
Output is correct |
81 |
Correct |
36 ms |
17996 KB |
Output is correct |
82 |
Correct |
30 ms |
18004 KB |
Output is correct |
83 |
Correct |
29 ms |
18004 KB |
Output is correct |
84 |
Correct |
29 ms |
17980 KB |
Output is correct |
85 |
Correct |
27 ms |
17996 KB |
Output is correct |
86 |
Correct |
28 ms |
18024 KB |
Output is correct |