Submission #1558505


Source Code Expand

#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<fstream>
#include<sstream>
#include<queue>
#include<iterator>
#include<stack>

using namespace std;

#define st first
#define nd second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REV(a) reverse(a.begin(),a.end())
#define SORT(a) sort(a.begin(),a.end())
#define inf (int)1e9
#define linf (long long)1e18

typedef long long ll;
typedef short int si;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

int n,a[100000],mx=0,mm;
ll ans=0;

int main() {
		cin>>n;
		FOR(i,0,n)cin>>a[i],mx=max(mx,a[i]),mm=min(mm,a[i]);
		sort(a,a+n);
		FOR(i,mm-1,mx+1){
				ans=max(ans,upper_bound(a,a+n,i+1)-lower_bound(a,a+n,i-1));
		}
		cout<<ans<<endl;




  return 0;
}

Submission Info

Submission Time
Task C - Together
User FelixChen
Language C++14 (GCC 5.4.1)
Score 0
Code Size 967 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:43:62: error: no matching function for call to ‘max(ll&, long int)’
     ans=max(ans,upper_bound(a,a+n,i+1)-lower_bound(a,a+n,i-1));
                                                              ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from ./Main.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
./Main.cpp:43:62: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘long int’)
     ans=max(ans,upper_bound(a,a+n,i+1)-lower_bound(a,a+n,i-1));
                                                      ...