답안 #1007965

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007965 2024-06-26T03:36:48 Z Rolo678 3단 점프 (JOI19_jumps) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int>a(n+1);
    for(int i = 1;i<=n;i++)
    {
        cin >> a[i];
    }
    vector<vector<pair<int,int>>>p(n+1);
      for(int i = 1;i<=n;i++)
    {
              long long mx = 0;
             for(int j = i+1;j<=n;j++)
            {
                 if(a[j] >= mx )
                 {
                     p[i].push_back({a[j],j});
                 }
                 mx = max(a[j],mx);
           }

    }

    int q;
    cin >> q;
    while(q--)
    {
        int l,r;
        cin >> l >> r;
        long long ans = 0;
        int a1,b,c;
        for(int i = l;i<=r-2;i++)
        {
            for(auto j :p[i])
            {
                if(j.second > r-1)
                {
                    continue;
                }

                for(int k = 2*(j.second) - i;k <= r;k++)
                {
                    if(k<1 || !(k -j.second >= j.second - i )|| k <=j.second || k<=i)
                    {
                        continue;
                    }
                    ans = max(ans,a[i]+j.first+a[k]);

                }
            }
        }

        cout << ans  <<'\n';

    }
}

Compilation message

jumps.cpp: In function 'int main()':
jumps.cpp:23:34: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, long long int&)'
   23 |                  mx = max(a[j],mx);
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from jumps.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:
jumps.cpp:23:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   23 |                  mx = max(a[j],mx);
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from jumps.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:
jumps.cpp:23:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   23 |                  mx = max(a[j],mx);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from jumps.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:
jumps.cpp:23:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   23 |                  mx = max(a[j],mx);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from jumps.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:
jumps.cpp:23:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   23 |                  mx = max(a[j],mx);
      |                                  ^
jumps.cpp:51:52: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   51 |                     ans = max(ans,a[i]+j.first+a[k]);
      |                                                    ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from jumps.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:
jumps.cpp:51:52: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   51 |                     ans = max(ans,a[i]+j.first+a[k]);
      |                                                    ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from jumps.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:
jumps.cpp:51:52: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   51 |                     ans = max(ans,a[i]+j.first+a[k]);
      |                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from jumps.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:
jumps.cpp:51:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |                     ans = max(ans,a[i]+j.first+a[k]);
      |                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from jumps.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:
jumps.cpp:51:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |                     ans = max(ans,a[i]+j.first+a[k]);
      |                                                    ^
jumps.cpp:35:13: warning: unused variable 'a1' [-Wunused-variable]
   35 |         int a1,b,c;
      |             ^~
jumps.cpp:35:16: warning: unused variable 'b' [-Wunused-variable]
   35 |         int a1,b,c;
      |                ^
jumps.cpp:35:18: warning: unused variable 'c' [-Wunused-variable]
   35 |         int a1,b,c;
      |                  ^