#include "mountains.h"
#include <vector>
#include <iostream>
using namespace std;
long long int tag[1005][1005],no,num[1005],tag2[1005];
int maximum_deevs(std::vector<int> y) {
int n=y.size(),ans=0;
for(int i=0;i<n;i++)
{
int tmp=0;
double ma=-999999999999;
for(int j=i-1;j>=0;j--)
{
if((double)(y[i]-y[j])/(double)(i-j)>=ma)
{
tmp++;
tag[i][tmp]=j;
ma=(double)(y[i]-y[j])/(double)(i-j);
}
}
ma=-999999999999;
for(int j=i+1;j<n;j++)
{
if((double)(y[i]-y[j])/(double)(i-j)>=ma)
{
tmp++;
tag[i][tmp]=j;
ma=(double)(y[i]-y[j])/(double)(i-j);
}
}
num[i]=tmp;
//cout<<num[i]<<endl;
}
while(true)
{
long long int mi=99999,p;
for(int i=0;i<n;i++)
{
if(tag2[i]==1)continue;
if(num[i]<mi)
{
mi=num[i];
p=i;
}
}
if(mi==99999)break;
ans++;
tag2[p]=1;
//cout<<p<<endl;
for(int i=1;i<=mi;i++)
{
tag2[tag[p][i]]=1;
//cout<<tag[p][i]<<" ";
}
//cout<<endl;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |