#include <bits/stdc++.h>
#include "mountains.h"
#define int long long
using namespace std;
struct angle{
int y,x;
angle(int y,int x):y(y),x(x){}
bool operator< (const angle &a)const{
if(a.x<0&&x>=0)
return true;
if(x<0&&a.x>=0)
return false;
return abs(y)*abs(a.x)<=abs(a.y)*abs(x);
}
};
int32_t maximum_deevs(vector<int32_t>v){
int n=v.size();
int dp[n];
dp[n-1]=1;
for(int i=n-2;i>=0;i--){
dp[i]=0;
angle mx(1,1);
for(int j=i+1;j<n;j++){
angle ang(j-i,v[i]-v[j]);
if(j==i+1)mx=ang;
if(ang<mx){
dp[i]=max(dp[i],dp[j]+1);
}else
mx=(ang);
///cout<<i<<' '<<j<<' '<<mx.y<<' '<<mx.x<<' '<<ang.y<<' '<<ang.x<<' '<<(ang<mx)<<'\n';
}
}
int ans=-1;
for(int i=0;i<n;i++)
ans=max(ans,dp[i]);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |