답안 #530456

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
530456 2022-02-25T11:51:24 Z ala2 Mountains (IOI17_mountains) C++14
0 / 100
1 ms 272 KB
#include<bits/stdc++.h>

#include "mountains.h"
#include <vector>
using namespace std;
int v[10010];
int a[10000];
int n;
int mx;
void f(int i)
{
    if(i==n)
    {
        int is=0;
        for(int ii=0;ii<n;ii++)
        {
            for(int jj=ii+1;jj<n;jj++)
            {
                if(v[ii]==v[jj]&&v[ii]==1)
                {
                    long double m= ( (1.0*(a[jj]-a[ii]) ) / ( (jj-ii)*1.0) );
                    long double b=a[ii]-m*ii;
                    //int is=0;
                    int bb=0;
                    for(int k=ii+1;k<jj;k++)
                    {
                        long double x=m*k+b;
                        if(a[k]>x){
                            is=1;

                        }

                    }
                    if(is==0)
                        return ;
                }
            }
        }

        int g=0;
        for(int bb=0;bb<n;bb++)
        {
       //     cout<<v[bb]<<" ";
            g+=v[bb];
        }
        mx=max(mx,g);
        return ;
    }
    v[i]=0;
    f(i+1);
    v[i]=1;
    f(i+1);
}
int maximum_deevs(vector<int> y) {
	n=y.size();
	for(int i=0;i<n;i++)
        a[i]=y[i];
    mx=1;
    f(0);
	return mx;
}

Compilation message

mountains.cpp: In function 'void f(int)':
mountains.cpp:24:25: warning: unused variable 'bb' [-Wunused-variable]
   24 |                     int bb=0;
      |                         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 272 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 272 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 272 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 272 KB Output isn't correct
5 Halted 0 ms 0 KB -