This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "mountains.h"
#include <vector>
using namespace std;
using ll = long long;
#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(ll ax, ll bx, ll cx, ll ay, ll by, ll cy){
return (ax*by + bx*cy + cx*ay - ay*bx - by*cx - cy*ax)>=0;
}
int maximum_deevs(vector<int> y) {
n = y.size();
dp[0][1]=1;
forsn(i, 1, n){
int lst = i-1, sum=1;
dp[i][i+1]=1;
dforn(j, i){
if(clockwise(j, lst, i, y[j], y[lst], y[i])){
sum+=dp[j+1][lst];
lst=j;
}
dp[j][i+1]=max(sum+dp[j][lst], dp[j][i]);
}
}
return dp[0][n];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |