이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dl double
#define st first
#define nd second
#define II pair <int, int>
#include "mountains.h"
using namespace std;
struct Node {
ll x, y;
bool operator <(const Node &O) const {
return x * O.y - y * O.x >= 0;
}
};
int maximum_deevs(vector<int> y) {
int n = y.size();
y.resize(n + 1);
for (int i = n; i > 0; i --)
y[i] = y[i - 1];
vector <vector <int>> f(n + 1, vector <int> (n + 1, 0));
for (int r = 1; r <= n; r ++) {
f[r][r] = 1;
int last = r, sum = 0;
for (int l = r - 1; l > 0; l --) {
Node u = {last - l, y[last] - y[l]}, v = {r - l, y[r] - y[l]};
if (u < v) {
sum += f[l + 1][last - 1];
last = l;
}
f[l][r] = max(f[l][r - 1], f[l][last - 1] + sum + 1);
}
}
return f[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... |