제출 #299839

#제출 시각아이디문제언어결과실행 시간메모리
299839MarcoMeijerMountains (IOI17_mountains)C++14
100 / 100
45 ms16256 KiB
#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<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
 
const int INF=1e9;
const int MX=1e5;
const ld EPS=1e-17;
 
ll cross(ii a, ii b) {return a.fi*b.se - b.fi*a.se;}
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 ccw(subt(b,a), subt(c,a));}

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...