Submission #220764

# Submission time Handle Problem Language Result Execution time Memory
220764 2020-04-08T18:02:53 Z Toirov_Sadi Triple Jump (JOI19_jumps) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int q;
int l;
int r;
int d[N];
int main()
{
    #ifdef FILE
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> d[i];
    }
    cin >> q;
    while(q --){
        long long sum = 0;
        cin >> l >> r;
        for(int a = l; a <= r; a ++){
            for(int b = a + 1; b <= r; b ++){
                for(int c = 2 * b - a; c <= r; c ++){
                    sum = max(sum, d[a] + d[b] + d[c]);
                }
            }
        }
        cout << sum << "\n";
    }
}

Compilation message

jumps.cpp: In function 'int main()':
jumps.cpp:38:54: error: no matching function for call to 'max(long long int&, int)'
                     sum = max(sum, d[a] + d[b] + d[c]);
                                                      ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from jumps.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
jumps.cpp:38:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
                     sum = max(sum, d[a] + d[b] + d[c]);
                                                      ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from jumps.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
jumps.cpp:38:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
                     sum = max(sum, d[a] + d[b] + d[c]);
                                                      ^
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:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
jumps.cpp:38:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                     sum = max(sum, d[a] + d[b] + d[c]);
                                                      ^
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:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
jumps.cpp:38:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                     sum = max(sum, d[a] + d[b] + d[c]);
                                                      ^
jumps.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("input.txt", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~