#include "mountains.h"
#include <vector>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forsn(i, s, n) for(int i=s; i<(int)n; ++i)
#define dforn(i, n) for(int i=n-1; i>=0; --i)
const int MAXN = 2010;
int n, dp[MAXN][MAXN];
bool clockwise(int ax, int bx, int cx, int ay, int by, int cy){
return (ax*by + bx*cy + cx*ay - ay*bx - by*cx - cy*bx)>=0;
}
int maximum_deevs(vector<int> y) {
n = y.size();
forsn(i, 1, n){
int lst = i-1, sum=1;
dforn(j, i-1){
if(clockwise(j, lst, i, y[j], y[lst], y[i])){
sum+=dp[j+1][lst];
lst=j;
}
dp[j][i]=max(sum+dp[j][lst], dp[j][i-1]);
}
}
return dp[0][n-1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |