제출 #489782

#제출 시각아이디문제언어결과실행 시간메모리
489782marcoskalGap (APIO16_gap)C++14
컴파일 에러
0 ms0 KiB
#include "gap.h"
#include <vector>

long long findGap(int T, int N)
{
  	long long first, last, first1, last1;
  	MinMax(0, 1000000000000000001ll, &first, &last);
  	long long step=(last-first)/(N-1);
  	std::vector<long long> v;
  	v.push_back(first);
  	long long ans=step, cntr=0;
  	for(int i=first;i<=last+1;i+=step)
    {
        //cout<<i+1<<" "<<i+step<<" "<<endl;
    	MinMax(i+1, i+step, &first1, &last1);
      	if(first1!=-1){
      		v.push_back(first1);
          	cntr++;
      	}
      	if(last1!=-1&&last1!=first1){
      		v.push_back(last1);
          	cntr++;
      	}
          	ans=max(ans, v[cntr]-v[cntr-1]);
    }
    //for(int i=0;i<v.size();i++)
        //cout<<v[i]<<" ";
    //cout<<endl;
	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:24:16: error: 'max' was not declared in this scope; did you mean 'std::max'?
   24 |            ans=max(ans, v[cntr]-v[cntr-1]);
      |                ^~~
      |                std::max
In file included from /usr/include/c++/10/vector:60,
                 from gap.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~