Submission #768195

#TimeUsernameProblemLanguageResultExecution timeMemory
768195raysh07Gap (APIO16_gap)C++17
Compilation error
0 ms0 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; long long findGap(int t, int n) { long long mx, mn; MinMax(1, (long long)1e18, &mn, &mx); if (t == 1){ vector <int> a; a.push_back(mn); a.push_back(mx); while (a.size() < n){ MinMax(mn + 1, mx - 1, &mn, &mx); a.push_back(mn); if (mn != mx) a.push_back(mx); } sort(a.begin(), a.end()); long long ans = 0; for (int i = 1; i < n; i++) ans = max(ans, a[i] - a[i - 1]); return ans; } long long ans = (mx - mn + n - 1) / n; long long last = mn; //go from s to t, but make jumps of size ans long long curr = mn + 1; while (curr <= mx){ //query [curr, curr + ans] long long mi, ma; MinMax(curr, curr + ans, &mi, &ma); curr += ans; if (mi == -1){ continue; } ans = max(mi - last, ans); last = ma; } return ans; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:16:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |      while (a.size() < n){
      |             ~~~~~~~~~^~~
gap.cpp:25:64: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   25 |      for (int i = 1; i < n; i++) ans = max(ans, a[i] - a[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:25:64: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   25 |      for (int i = 1; i < n; i++) ans = max(ans, a[i] - a[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:25:64: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   25 |      for (int i = 1; i < n; i++) ans = max(ans, a[i] - a[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:25:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |      for (int i = 1; i < n; i++) ans = max(ans, a[i] - a[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:25:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |      for (int i = 1; i < n; i++) ans = max(ans, a[i] - a[i - 1]);
      |                                                                ^