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>
using namespace std;
vector<int> a;
bool can(int i, int j) {
double slope = a[i] == a[j] ? 0 : (i-j) / (a[i]-a[j]);
double curr = a[i];
for(int k = i+1; k < j; k++) {
curr += slope;
if ((double) a[k] > curr) {
return true;
}
}
return false;
}
int maximum_deevs(std::vector<int> y) {
int n = y.size();
a = y;
vector<int> dp(n+1, 1);
for(int i = 0; i < n; i++) {
for(int j = i+1; j < n; j++) {
if (can(i, j)) {
dp[j] = max(dp[j], dp[i]+1);
}
}
}
// for(int i : dp) {
// cout << i << " ";
// }
return *max_element(dp.begin(), dp.end());
}
//int main() {
//
//}
# | 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... |