Submission #306563

#TimeUsernameProblemLanguageResultExecution timeMemory
306563CaroLindaMountains (IOI17_mountains)C++14
0 / 100
1 ms256 KiB
#include "mountains.h" #include <bits/stdc++.h> #define ll long long #define sz(x) (int)(x.size()) using namespace std ; template<class T> class Point { public: T x , y ; Point(){ x = y = 0 ; } Point(T a, T b) { x = a ; y = b ; } T operator % (Point other) const { return x*other.y - y*other.x ; } T operator * (Point other) const { return x*other.x + y*other.y ; } Point operator - (Point other) const { return Point(x-other.x, y-other.y) ; } } ; int maximum_deevs(vector<int> y) { int n = sz(y) ; vector< Point<ll> > ponto(n) ; for(int i = 0 ; i< n ; i++ ) ponto[i].x = i , ponto[i].y = y[i] ; vector< vector<int> > dp(n+5, vector<int>(n+5,0) ) ; vector< int > meuUltimo(n) ; for(int i = 0 ; i < n ; i++ ) for(int j = i ; j < n ; j++ ) dp[i][j] = 1 ; for(int i = 0 ; i <n-1 ; i++ ) meuUltimo[i] = i+1 ; for(int r = 2 ; r <= n ; r++ ) { for(int i = 0 ; i <= r-2 ; i++ ) dp[i][r-1] = dp[i][r-2] ; for(int i = r-2 ; i >= 0 ; i-- ) if( i == n || (ponto[meuUltimo[i]] - ponto[i]) % (ponto[r]-ponto[i]) >= 0 ) { if(meuUltimo[i] + 1 <= r-1 ) dp[i][r-1] += dp[ meuUltimo[i]+1 ][r-1] ; meuUltimo[i] = r ; } } int mx = 1 ; for(int i = 0 ; i < n ; i++ ) mx = max(mx, *max_element(dp[i].begin() , dp[i].end())) ; return mx ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...