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>
#include <vector>
using namespace std;
const int N = 2000 + 2;
int dp[N][N];
vector<int> a;
#define pnt complex<long long>
long long cross(pnt x, pnt y)
{
return imag(conj(x) * y);
}
long long cross(pnt x, pnt y, pnt z)
{
return cross(y - x, z - y);
}
int maximum_deevs(std::vector<int> y)
{
a = y;
int n = (int)y.size();
for (int i = 0; i < n; ++i)
{
dp[i][i] = 1;
int kah = i;
int sum = 0;
for (int j = i - 1; j >= 0; --j)
{
dp[j][i] = dp[j][i - 1];
if (cross(pnt(j, a[j]), pnt(kah, a[kah]), pnt(i, a[i])) >= 0 )
{
sum += dp[j + 1][kah - 1];
kah = j;
}
dp[j][i] = max(dp[j][i], sum + 1 + dp[j][kah - 1]);
}
}
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... |