Submission #1015160

# Submission time Handle Problem Language Result Execution time Memory
1015160 2024-07-06T06:51:51 Z vjudge1 Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
#include "gap.h"
#include <bits/stdc++.h>
// #include "grader.cpp"
using namespace std;
long long solve(int n){
	long long mn,mx;
	long long s=0,t=1e18;
	vector<int> arr;
	vector<int> a1;
	while(mn+1<mx){
		MinMax(s,t,&mn,&mx);
		if(mn==-1)
			break;
		s=mn+1;
		t=mx-1;
		arr.push_back(mn);
		a1.push_back(mx);
	}
	reverse(a1.begin(), a1.end());
	for(long long i:a1)
		arr.push_back(i);
	long long g=0;
	for(int i=1;i<arr.size();i++)
		g=max(g,arr[i]-arr[i-1]);
	return g;
}
long long findGap(int T, int N)
{
	// if(T==1)
	// 	return solve(N);
	long long mn,mx;
	long long s=0,t=1e18;
	MinMax(s,t,&mn,&mx);
	s=mn+1,t=mx;
	long long gap=(t-s)/(N-1);
	long long ans=0;
	long long pre=mn;
	while(s<t){
		MinMax(s,min(s+gap,t),&mn,&mx);
		if(mn==-1)
			s+=gap;
		else{
			gap=max(gap,mn-pre);
			s=mx+1;
			pre=mx;
		}
	}
	return gap;
}

Compilation message

gap.cpp: In function 'long long int solve(int)':
gap.cpp:23:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i=1;i<arr.size();i++)
      |              ~^~~~~~~~~~~
gap.cpp:24:26: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   24 |   g=max(g,arr[i]-arr[i-1]);
      |                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from gap.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
gap.cpp:24:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   24 |   g=max(g,arr[i]-arr[i-1]);
      |                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from gap.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
gap.cpp:24:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   24 |   g=max(g,arr[i]-arr[i-1]);
      |                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from gap.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
gap.cpp:24:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |   g=max(g,arr[i]-arr[i-1]);
      |                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from gap.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
gap.cpp:24:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |   g=max(g,arr[i]-arr[i-1]);
      |                          ^
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:36:12: warning: unused variable 'ans' [-Wunused-variable]
   36 |  long long ans=0;
      |            ^~~