Submission #509586

#TimeUsernameProblemLanguageResultExecution timeMemory
509586CSQ31Just Long Neckties (JOI20_ho_t1)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
int a[200001],b[200001];
long long int s[200001];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n+1;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	sort(b,b+n);
	sort(a,a+n+1);
	for(int i=n;i>0;i--){
		s[i] = max(0,a[i] - b[i-1]);
		if(i!=n)s[i] = max(s[i],s[i+1]);
	}
	int cur = 0;
	for(int i=0;i<=n;i++){
	    int ans = cur;
		if(i!=n){
			ans = max(ans,s[i+1]);
			cur=max(cur,a[i]-b[i]);
		}
		cout<<ans<<" ";
	}
	
	
}

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:21:24: error: no matching function for call to 'max(int&, long long int&)'
   21 |    ans = max(ans,s[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 ho_t1.cpp:1:
/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:
ho_t1.cpp:21:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   21 |    ans = max(ans,s[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 ho_t1.cpp:1:
/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:
ho_t1.cpp:21:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   21 |    ans = max(ans,s[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 ho_t1.cpp:1:
/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:
ho_t1.cpp:21:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |    ans = max(ans,s[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 ho_t1.cpp:1:
/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:
ho_t1.cpp:21:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |    ans = max(ans,s[i+1]);
      |                        ^