답안 #763044

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763044 2023-06-22T02:42:53 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
컴파일 오류
0 ms 0 KB
#ifdef MINHDEPTRAI

#include "/Library/Developer/CommandLineTools/usr/include/c++/v1/bits/stdc++.h"  
#include <chrono>
#define __gcd(a, b) gcd(a, b)
using namespace std ::chrono;
#else 
#include <bits/stdc++.h>
#endif

using namespace std;
#define foru(i, a, b) for(int i = a; i <= b; ++i)
#define ford(i, a, b) for(int i = a; i >= b; --i)
#define IOS ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp(a, b) make_pair(a, b)
#define endl '\n'

#define int long long
const int maxN = 2e5+ 5;
const int mod = 998244353;
const long long inf = 1e17;
int n, arr[maxN], b[maxN], ans[maxN];
int prefix[maxN], suffix[maxN];
map<int, int> pos;
bool used[maxN];
signed main(){
    // input
    IOS

    cin >> n;
    foru(i, 1, n + 1) {
        cin >> arr[i];
        pos[arr[i]] = i;
    }

    foru(i, 1, n){
        cin >> b[i];
    }
    sort(arr + 1, arr + 2 + n);
    sort(b + 1, b + 1 + n);
    prefix[0] = 0;

    foru(i, 1, n){
        prefix[i] = max( prefix[i - 1],  max(arr[i] - b[i], 0)); 
    }
    suffix[n + 1] = 0;

    ford(i, n, 1){
        suffix[i] = max(suffix[i + 1],  arr[i + 1] - b[i]);
    }

    foru(i, 1, n + 1){
        ans[pos[arr[i]]] = max(prefix[i - 1], suffix[i]);
    }

    foru(i, 1, n + 1) cout << ans[i] << " ";
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:45:62: error: no matching function for call to 'max(long long int, int)'
   45 |         prefix[i] = max( prefix[i - 1],  max(arr[i] - b[i], 0));
      |                                                              ^
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 ho_t1.cpp:9:
/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:
ho_t1.cpp:45:62: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |         prefix[i] = max( prefix[i - 1],  max(arr[i] - b[i], 0));
      |                                                              ^
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 ho_t1.cpp:9:
/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:
ho_t1.cpp:45:62: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |         prefix[i] = max( prefix[i - 1],  max(arr[i] - b[i], 0));
      |                                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ho_t1.cpp:9:
/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:
ho_t1.cpp:45:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |         prefix[i] = max( prefix[i - 1],  max(arr[i] - b[i], 0));
      |                                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ho_t1.cpp:9:
/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:
ho_t1.cpp:45:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |         prefix[i] = max( prefix[i - 1],  max(arr[i] - b[i], 0));
      |                                                              ^