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 <bits/stdc++.h>
using namespace std;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define RE(a,b) REP(a,0,b)
#define FOR(a,b) for(auto& a:b)
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int INF=1e9;
const int MX=1e5;
const ld EPS=1e-17;
int cross(ii a, ii b) {return a.fi*b.se - b.se*a.fi;}
bool ccw(ii a, ii b) {return cross(a,b) >= 0;}
ii subt(ii a, ii b) {return {a.fi-b.fi, a.se-b.se};}
bool ccw(ii A, ii B, ii C) {
return ((B.fi - A.fi) * 1LL * (C.se - A.se) - (C.fi - A.fi) * 1LL * (B.se - A.se)) >= 0;
}
int maximum_deevs(vi y) {
int n = y.size();
vii C;
RE(i,n) C.pb({i,y[i]});
vector<vi> dp; dp.assign(n,vi(n,0));
RE(i,n) dp[i][i] = 1;
RE(r,n) {
int last=r, sm=0;
REV(l,0,r) {
dp[l][r] = dp[l][r-1];
if(ccw(C[l],C[last],C[r])) {
sm += last ? dp[l+1][last-1] : 0;
last = l;
}
dp[l][r] = max(dp[l][r], 1 + sm + (last ? dp[l][last-1] : 0));
}
}
return dp[0][n-1];
}
# | 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... |