Submission #803267

#TimeUsernameProblemLanguageResultExecution timeMemory
803267Username4132Mountains (IOI17_mountains)C++14
0 / 100
1 ms340 KiB
#include "mountains.h" #include <vector> using namespace std; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define forsn(i, s, n) for(int i=s; i<(int)n; ++i) #define dforn(i, n) for(int i=n-1; i>=0; --i) const int MAXN = 2010; int n, dp[MAXN][MAXN]; bool clockwise(int ax, int bx, int cx, int ay, int by, int cy){ return (ax*by + bx*cy + cx*ay - ay*bx - by*cx - cy*ax)>=0; } int maximum_deevs(vector<int> y) { n = y.size(); dp[0][1]=1; forsn(i, 1, n){ int lst = i-1, sum=1; dp[i][i+1]=1; dforn(j, i){ if(clockwise(j, lst, i, y[j], y[lst], y[i])){ sum+=dp[j+1][lst]; lst=j; } dp[j][i+1]=max(sum+dp[j][lst], dp[j][i]); } } return dp[0][n]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...