답안 #1094283

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094283 2024-09-29T09:03:41 Z mingga Gap (APIO16_gap) C++17
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
#include "gap.h"

using namespace std;

#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define inf 2e18
#define fast_cin()                  \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define out(file) freopen(file, "w", stdout)
#define in(file) freopen(file, "r", stdin)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
// #define int long long
int MOD = 1e9 + 7;

long long findGap(int T, int N) {
    if(T == 1) {
        long long mn, mx;
        long long lb = 0, rb = 1e18;
        int l = 0, r = N - 1;
        vector<int> a(N, 0);
        while(l <= r) {
            MinMax(lb, rb, &mn, &mx);
            a[l] = mn, a[r] = mx;
            lb = mn + 1, rb = mx - 1;
            l++,
            r--;
        }
        long long ans = 0;
        for(int i = 1; i < N; i++) ans = max(ans, a[i] - a[i - 1]);
        return ans;
    }
    return 0;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:37:66: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   37 |         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: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:
gap.cpp:37:66: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   37 |         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: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:
gap.cpp:37:66: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   37 |         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: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:
gap.cpp:37:66: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   37 |         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: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:
gap.cpp:37:66: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   37 |         for(int i = 1; i < N; i++) ans = max(ans, a[i] - a[i - 1]);
      |                                                                  ^