이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
int n;
vector<p> v;
int dp[2020][2020];
int ccw(int _a, int _b, int _c){
p a = v[_a], b = v[_b], c = v[_c];
ll res = a.x*b.y + b.x*c.y + c.x*a.y;
res -= b.x*a.y + c.x*b.y + a.x*c.y;
if(res > 0) return 1;
if(res) return -1;
return 0;
}
int maximum_deevs(vector<int> h){
n = h.size(); v.resize(n+1);
for(int i=1; i<=n; i++) v[i].x = i, v[i].y = h[i-1];
for(int i=1; i<=n; i++){
dp[i][i] = dp[i-1][i] = 1;
int left = i - 1, v = 0;
for(int j=i-2; j>0; j--){
if(ccw(j, left, i) >= 0){
v += dp[j+1][left-1];
left = j;
}
dp[j][i] = max(dp[j][i-1], v + dp[j][left-1] + 1);
}
}
return dp[1][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... |