Submission #240366

#TimeUsernameProblemLanguageResultExecution timeMemory
240366ctziapoGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include "gap.h" #include<algorithm> #include<cmath> #include<vector> using namespace std; long long findGap(int T, int N) { if(T==1){ long long int mi,ma; int n=N; MinMax(1,1000000000000000000,&mi,&ma); long long int a[n+3]; //cout<<mi<<" "<<ma<<endl; a[1]=mi; a[n]=ma; for(int i=2;i<=n/2;i++){ //cout<<1; mi++; ma--; //cout<<" 22 "<<mi<<" "<<ma; MinMax(mi,ma,&mi,&ma); // cout<<mi<<" "<<ma<<endl; a[i]=mi; a[n-i+1]=ma; } mi++; ma--; if(n%2==1){ MinMax(mi,ma,&mi,&ma); a[n/2+1]=mi; } long long int ans=0; for(int i=2;i<=n;i++){ ans=max(ans,a[i]-a[i-1]); } return ans; } else { long long int mi,ma; int n=N; MinMax(1,1000000000000000000,&mi,&ma); long long int a[n+3]; vector < int > v; long long int d=(ma-mi+1)/n; long long int s=mi; long long int ans=0; while(s<=ma){ long long int t1,t2; MinMax(s,s+d,&t1,&t2); if(t1!=-1) v.push_back(t1); if(t2!=-1) v.push_back(t2); // cout<<t1<<" "<<t2; s+=d; } for(int i=1;i<v.size();i++){ ans=max(ans,v[i]-v[i-1]); } return ans; } }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:75:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=1;i<v.size();i++){
                     ~^~~~~~~~~
gap.cpp:76:36: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type)'
             ans=max(ans,v[i]-v[i-1]);
                                    ^
In file included from /usr/include/c++/7/algorithm:61:0,
                 from gap.cpp:2:
/usr/include/c++/7/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++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
gap.cpp:76:36: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}')
             ans=max(ans,v[i]-v[i-1]);
                                    ^
In file included from /usr/include/c++/7/algorithm:61:0,
                 from gap.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
gap.cpp:76:36: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}')
             ans=max(ans,v[i]-v[i-1]);
                                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from gap.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
gap.cpp:76:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             ans=max(ans,v[i]-v[i-1]);
                                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from gap.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
gap.cpp:76:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             ans=max(ans,v[i]-v[i-1]);
                                    ^
gap.cpp:53:23: warning: unused variable 'a' [-Wunused-variable]
         long long int a[n+3];
                       ^