Submission #762938

# Submission time Handle Problem Language Result Execution time Memory
762938 2023-06-22T01:32:01 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

int n;
vector<pair<int, int>> a;
vector<int> b, prefLeft, prefRight, results;

int main()
{
    // freopen("inp.txt", "r", stdin);

    ios::sync_with_stdio(false);

    cin >> n;
    a.resize(n + 3); b.resize(n + 3);
    for (int i = 1; i <= n + 1; i++)
    {
        cin >> a[i].first;
        a[i].second = i;
    }
    for (int i = 1; i <= n; i++)
        cin >> b[i];

    sort(a.begin() + 1, a.begin() + n + 2);
    sort(b.begin() + 1, b.begin() + n + 1);

    prefLeft.resize(n + 3);
    for (int i = 1; i <= n; i++)
        prefLeft[i] = max(prefLeft[i - 1], max(a[i].first - b[i], 0ll));

    prefRight.resize(n + 3);
    for (int i = n + 1; i >= 2; i--)
        prefRight[i] = max(prefRight[i + 1], max(a[i].first - b[i - 1], 0ll));

    /*
    for (int i = 1; i <= n + 1; i++)
        cout << prefLeft[i] << ' ';
    cout << endl;
    for (int i = 1; i <= n + 1; i++)
        cout << prefRight[i] << ' ';
    cout << endl;
     */

    results.resize(n + 3);
    for (int i = 1; i <= n + 1; i++)
        results[a[i].second] = max(prefLeft[i - 1], prefRight[i + 1]);

    for (int i = 1; i <= n + 1; i++)
        cout << results[i] << ' ';
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:30:70: error: no matching function for call to 'max(int, long long int)'
   30 |         prefLeft[i] = max(prefLeft[i - 1], max(a[i].first - b[i], 0ll));
      |                                                                      ^
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: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:
ho_t1.cpp:30:70: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   30 |         prefLeft[i] = max(prefLeft[i - 1], max(a[i].first - b[i], 0ll));
      |                                                                      ^
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: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:
ho_t1.cpp:30:70: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   30 |         prefLeft[i] = max(prefLeft[i - 1], max(a[i].first - b[i], 0ll));
      |                                                                      ^
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: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:
ho_t1.cpp:30:70: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |         prefLeft[i] = max(prefLeft[i - 1], max(a[i].first - b[i], 0ll));
      |                                                                      ^
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: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:
ho_t1.cpp:30:70: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |         prefLeft[i] = max(prefLeft[i - 1], max(a[i].first - b[i], 0ll));
      |                                                                      ^
ho_t1.cpp:34:76: error: no matching function for call to 'max(int, long long int)'
   34 |         prefRight[i] = max(prefRight[i + 1], max(a[i].first - b[i - 1], 0ll));
      |                                                                            ^
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: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:
ho_t1.cpp:34:76: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   34 |         prefRight[i] = max(prefRight[i + 1], max(a[i].first - b[i - 1], 0ll));
      |                                                                            ^
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: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:
ho_t1.cpp:34:76: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   34 |         prefRight[i] = max(prefRight[i + 1], max(a[i].first - b[i - 1], 0ll));
      |                                                                            ^
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: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:
ho_t1.cpp:34:76: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |         prefRight[i] = max(prefRight[i + 1], max(a[i].first - b[i - 1], 0ll));
      |                                                                            ^
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: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:
ho_t1.cpp:34:76: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |         prefRight[i] = max(prefRight[i + 1], max(a[i].first - b[i - 1], 0ll));
      |                                                                            ^