Submission #126019

#TimeUsernameProblemLanguageResultExecution timeMemory
126019zeyad49Mountains (IOI17_mountains)C++17
100 / 100
39 ms14200 KiB
#include "mountains.h" #define x first #define y second using namespace std; typedef pair<long long,long long> point; const int MAX = 2005; int dp[MAX][MAX]; point p[MAX]; long long ccw(point a, point b, point c) { return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x); } int maximum_deevs(vector<int> y) { int n = y.size(); for (int i = 0; i < n; i++) { p[i].y = y[i]; p[i].x = i; } for (int r = 0; r < n; r++) { int sum = 0, last = r; dp[r][r] = 1; for (int l = r - 1; l >= 0; l--) { dp[l][r] = dp[l][r - 1]; if (ccw(p[l], p[last], p[r]) >= 0) { sum += dp[l + 1][last-1]; last = l; } dp[l][r] = max(dp[l][r], 1 + sum + dp[l][last-1]); } } 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...