# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
385233 | 2021-04-03T19:08:35 Z | Ahmad_Hasan | Mountains (IOI17_mountains) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "mountains.h" #define int long long using namespace std; int maximum_deevs(vector<int>v){ int n=v.size(); long double pi=acos(-1.0); int dp[n]; dp[n-1]=1; for(int i=n-2;i>=0;i--){ dp[i]=0; long double mx=-1; for(int j=i+1;j<n;j++){ long double ang=atan2(j-i,v[i]-v[j])*180/pi; if(ang<mx){ dp[i]=max(dp[i],dp[j]+1); } mx=max(mx,ang); /// cout<<i<<' '<<j<<' '<<mx<<' '<<j-i<<' '<<v[i]-v[j]<<'\n'; } } int ans=-1; for(int i=0;i<n;i++) ans=max(ans,dp[i]); return ans; }