/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'void Try()':
foo.cc:32:19: error: no matching function for call to 'max(long long int, int)'
   32 |         ans += max(0LL, B[i] - A[i]);
      |                ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from foo.cc:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
foo.cc:32:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   32 |         ans += max(0LL, B[i] - A[i]);
      |                ~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
foo.cc:32:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   32 |         ans += max(0LL, B[i] - A[i]);
      |                ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
foo.cc:32:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |         ans += max(0LL, B[i] - A[i]);
      |                ~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
foo.cc:32:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |         ans += max(0LL, B[i] - A[i]);
      |                ~~~^~~~~~~~~~~~~~~~~~

Code

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'

const int nn = 1e5 + 17, mod = 1e9 + 7;
int n, A[nn], B[nn];

void Try() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
    }
    
    for (int i = 1; i <= n; i++) {
        cin >> B[i];
    }
    
    ll ans = 0;
    priority_queue<int, vector<int>, greater<int>> Mn;
    
    int mx = 0;

    
    for (int i = n; i >= 1; i--) {
        mx = max(mx, B[i]);
        B[i] = mx;
    }
    
    for (int i = 1; i <= n; i++) {
        ans += max(0LL, B[i] - A[i]);
    }
    
    
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int t = 1;
    cin >> t;
    for (int i = 1; i <= t; i++) {
        Try();
    }

}

Information

Submit By
Type
Pretest
Problem
P1228 Business Strategy
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-01 07:10:06
Judged At
2025-09-01 07:10:06
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes