Submission #803260

#TimeUsernameProblemLanguageResultExecution timeMemory
803260Username4132Mountains (IOI17_mountains)C++14
0 / 100
0 ms212 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(); forsn(i, 1, n){ int lst = i-1, sum=1; dp[i-1][i]=1; dforn(j, i-1){ if(clockwise(j, lst, i, y[j], y[lst], y[i])){ sum+=dp[j+1][lst]; lst=j; } dp[j][i]=max(sum+dp[j][lst], dp[j][i-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...