Submission #146032

# Submission time Handle Problem Language Result Execution time Memory
146032 2019-08-21T16:13:15 Z fedoseevtimofey Triple Jump (JOI19_jumps) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

bool ok(int i, int j, int k) {
    vector <int> r = {i, j, k};
    sort(r.begin(), r.end());
    i = r[0], j = r[1], k = r[2];
    if (i == j || j == k) return false;
    return k - j >= j - i;
}

int solve(vector <int> a) {
    vector <pair <int, int>> b;
    int n = a.size();
    for (int i = 0; i < n; ++i) b.push_back({a[i], i});
    sort(b.rbegin(), b.rend());
    int ans = 0;
    for (int i = 0; i < min(b.size(), 5); ++i) {
        for (int j = 0; j < min(b.size(), 5); ++j) {
            for (int k = 0; k < n; ++k) {
                if (ok(b[i].second, b[j].second, k)) {
                    ans = max(ans, b[i].first + b[j].first + a[k]);
                }
            }
        }   
    }   
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector <int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        vector <int> a;
        for (int i = l; i <= r; ++i) a.push_back(A[i]);
        cout << solve(a) << '\n';
    }
}

Compilation message

jumps.cpp: In function 'int solve(std::vector<int>)':
jumps.cpp:22:40: error: no matching function for call to 'min(std::vector<std::pair<int, int> >::size_type, int)'
     for (int i = 0; i < min(b.size(), 5); ++i) {
                                        ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from jumps.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
jumps.cpp:22:40: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
     for (int i = 0; i < min(b.size(), 5); ++i) {
                                        ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from jumps.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
jumps.cpp:22:40: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
     for (int i = 0; i < min(b.size(), 5); ++i) {
                                        ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from jumps.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
jumps.cpp:22:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
     for (int i = 0; i < min(b.size(), 5); ++i) {
                                        ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from jumps.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
jumps.cpp:22:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
     for (int i = 0; i < min(b.size(), 5); ++i) {
                                        ^
jumps.cpp:23:44: error: no matching function for call to 'min(std::vector<std::pair<int, int> >::size_type, int)'
         for (int j = 0; j < min(b.size(), 5); ++j) {
                                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from jumps.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
jumps.cpp:23:44: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
         for (int j = 0; j < min(b.size(), 5); ++j) {
                                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from jumps.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
jumps.cpp:23:44: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
         for (int j = 0; j < min(b.size(), 5); ++j) {
                                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from jumps.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
jumps.cpp:23:44: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
         for (int j = 0; j < min(b.size(), 5); ++j) {
                                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from jumps.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
jumps.cpp:23:44: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
         for (int j = 0; j < min(b.size(), 5); ++j) {
                                            ^