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 <vector>
const int MAX_N = 2000;
int dp[MAX_N];
long long ccw(int x1, int y1, int x2, int y2, int x3, int y3) {
return (long long)x1 * y2 +
(long long)x2 * y3 +
(long long)x3 * y1 -
(long long)x1 * y3 -
(long long)x2 * y1 -
(long long)x3 * y2;
}
int maximum_deevs(std::vector<int> y) {
int res = 1;
for(int i = 0; i < y.size(); ++i) {
dp[i] = 1;
int best = i - 1;
for(int j = i - 1; j >= 0; --j) {
if(ccw(i, y[i], best, y[best], j, y[j]) <= 0)
best = j;
else
dp[i] = std::max(dp[j] + 1, dp[i]);
}
res = std::max(res, dp[i]);
}
return res;
}
Compilation message (stderr)
mountains.cpp: In function 'int maximum_deevs(std::vector<int>)':
mountains.cpp:18:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for(int i = 0; i < y.size(); ++i) {
| ~~^~~~~~~~~~
# | 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... |