This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize ("Ofast")
#include "mountains.h"
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
const int N = 2002 + 1000;
ll n, ans;
vector<ll> dp[N];
int maximum_deevs(vector<int> y) {
n = y.size();
ans = 0;
for (ll i = 0; i < n; i++) {
dp[i].push_back(i);
for (ll j = 0; j < i; j++) {
bool ok = 1;
for (ll idx : dp[j]) {
if (!ok) break;
bool ok2 = 0;
for (ll k = idx+1; k < i; k++) {
ld a = i;
ld b = idx;
ld c = k;
ld d = y[i];
ld e = y[idx];
ld f = y[k];
ld p = (d-e) / (a-b);
ld h = e + ((c-b) * p);
if (f > h) {
ok2 = 1;
break;
}
}
if (!ok2) ok = 0;
}
if (ok) {
if (dp[j].size()+1 > dp[i].size()) {
dp[i] = dp[j];
dp[i].push_back(i);
}
}
}
ll sz = dp[i].size();
ans = max(ans, sz);
}
return max(ans, 1ll);
}
# | 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... |