제출 #300089

#제출 시각아이디문제언어결과실행 시간메모리
300089a_playerGap (APIO16_gap)C++14
컴파일 에러
0 ms0 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; long long findGap(int T, int N){ if(T==1){ ll mx, mn; vector<ll> a(N); MinMax(0,2e18,&mn,&mx); a[0]=mn; a[N-1]=mx; int i=1; while(mx!=mn){ MinMax(mn+1,mx-1,&mn,&mx); if(mn==-1)break; a[i]=mn; a[N-i-1]=mx; i++; } int ans=0; for(int i=1;i<N;i++)ans=max(ans,a[i]-a[i-1]); cout<<ans; return 0; } ll mn,mx; MinMax(0,2e18,&mn,&mx); ll d=(mx-mn+N-1)/N; ll a=mn+1; ll b=mn+d; ll l=mn; ll ans=0; for(int i=0;i<N;i++){ if(b>=mx)b=mx-1; if(s>e)break; ll mnn,mxx; MinMax(a,b,&mnn,&mxx); if(mnn!=-1){ ans=max(ans,mnn-l); l=mxx; } a+=d; b+=d; } ans=max(ans,mx-l); cout<<ans; return 0; }

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:22:48: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   22 |     for(int i=1;i<N;i++)ans=max(ans,a[i]-a[i-1]);
      |                                                ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from gap.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
gap.cpp:22:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   22 |     for(int i=1;i<N;i++)ans=max(ans,a[i]-a[i-1]);
      |                                                ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from gap.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
gap.cpp:22:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   22 |     for(int i=1;i<N;i++)ans=max(ans,a[i]-a[i-1]);
      |                                                ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from gap.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
gap.cpp:22:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |     for(int i=1;i<N;i++)ans=max(ans,a[i]-a[i-1]);
      |                                                ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from gap.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
gap.cpp:22:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |     for(int i=1;i<N;i++)ans=max(ans,a[i]-a[i-1]);
      |                                                ^
gap.cpp:35:8: error: 's' was not declared in this scope
   35 |     if(s>e)break;
      |        ^
gap.cpp:35:10: error: 'e' was not declared in this scope
   35 |     if(s>e)break;
      |          ^