# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
755582 | ETheBest3 | Mountains (IOI17_mountains) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mountains.h"
#define lli long long
#define endl "\n"
#include <vector>
const lli MAXN=2005;
lli dp[MAXN][MAXN], N, ss, last;
struct points{
lli x, y;
};
points p[MAXN];
bool ccw(points a, points b, points c){
return (a.x*b.y+a.y*c.x+b.x*c.y)-(c.x*b.y+c.y*a.x+b.x*a.y)>=0;
}
int maximum_deevs(std::vector<int> y) {
N=y.size();
for(lli i=0; i<N; i++){
p[i]={i, y[i]};
}
for(lli i=0; i<N; i++)dp[i][i]=1;
for(lli r=0; r<N; r++){
last=r;
ss=0;
for(lli l=r-1; l>=0; l--){
dp[l][r]=dp[l][r-1];
if(ccw(p[l], p[last], p[r])){
ss+=dp[l+1][last-1];
last=l;
}
dp[l][r]=max(dp[l][r], 1+ss+dp[l][last-1]);
}
}
return dp[0][N-1];
}