Submission #125409

#TimeUsernameProblemLanguageResultExecution timeMemory
125409nhhoMountains (IOI17_mountains)C++14
100 / 100
36 ms14328 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) >= (long long)(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); } // for (int i = 0; i < n; i++) {for (int j = 0; j <= i; j++) printf("%d ", dp[j][i]); puts("");} 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...