Submission #125406

#TimeUsernameProblemLanguageResultExecution timeMemory
125406nhhoMountains (IOI17_mountains)C++14
0 / 100
4 ms376 KiB
#include <bits/stdc++.h> #include "mountains.h" using namespace std; constexpr int MAX = 2000; int dp[MAX][MAX]; bool CanSee(int a, int b, int c, vector<int>& y) { return (long long)(y[c] - y[a]) * (b - a) <= (y[b] - y[a]) * (c - a); } int maximum_deevs(vector<int> y) { int n = y.size(); for (int i = 0; i < n; i++) { dp[i][i] = 1; int la = i, add = 1; for (int j = i - 1; j >= 0; j--) if (la == i || CanSee(j, la, i, y)) { add += dp[j + 1][la - 1]; la = j; dp[j][i] = max(dp[j][i - 1], add); } else dp[j][i] = max(dp[j][i - 1], dp[j][la - 1] + add); } return dp[0][n - 1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...