답안 #721948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721948 2023-04-11T09:11:45 Z OttincaM Uplifting Excursion (BOI22_vault) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
#include "stdio.h"
using namespace std;
// #define int long long
 
int const LLINF = 1e9 + 1;
int const N = (10000 * 101) / 2 + 9;
int const ZER = 300000;
 
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #ifdef WTF
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    #endif
 
 
    int m;
    long long l; cin >> m >> l;
    int smn = 0, smf = 0;
    if (l >= N || l < -N){
        cout << "impossible\n";
        return 0;
    }
    vector <int> a(2 * m + 2), x, y, z;
    for(int i = 1; i <= 2 * m + 1; i ++){
         cin >> a[i];
         int K = a[i];
         while(K --){
            if(i - 1 - m >= 0){
                x.push_back(i - 1 - m);
                smn += i - 1 - m;
            } else if(i - 1 - m < 0){
                y.push_back(-(i - 1 - m));
                smf += i - 1 - m;
            } else {
                z.push_back(i - 1 - m);
            }
         }
    }
 
    vector <int> dp1(N, -LLINF), dp2(N, -LLINF);
    dp1[0] = 0;
    dp2[0] = 0;
    for(int k: x){
        for(int i = N - 1; i >= k; i --){
            dp1[i] = max(dp1[i], dp1[i - k] + 1);
        }
    }

    // for(int i = 0; i < N; i ++){
    //     cout << dp1[i] << " ";
    // }
    // cout << "\n";

    for(int k: y){
        for(int i = N - 1; i >= k; i --){
            dp2[i] = max(dp2[i], dp2[i - k] + 1);
        }
    }
    long long ans = -LLINF;
    if(l >= 0){
        for(int i = l; i < N; i ++){
            int j = i - l;
            ans = max(ans, dp1[i] + dp2[j]);
        }
    } else {
        l = -l;
        for(int i = l; i < N; i ++){
            int j = i - l;
            ans = max(ans, dp2[i] + dp1[j]);
        }
    }
    if(ans < 0){
        cout << "impossible\n";
    } else {
        cout << ans << "\n";
    }
    return 0;
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:67:43: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   67 |             ans = max(ans, dp1[i] + dp2[j]);
      |                                           ^
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/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from vault.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:
vault.cpp:67:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   67 |             ans = max(ans, dp1[i] + dp2[j]);
      |                                           ^
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/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from vault.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:
vault.cpp:67:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   67 |             ans = max(ans, dp1[i] + dp2[j]);
      |                                           ^
vault.cpp:73:43: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   73 |             ans = max(ans, dp2[i] + dp1[j]);
      |                                           ^
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/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from vault.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:
vault.cpp:73:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   73 |             ans = max(ans, dp2[i] + dp1[j]);
      |                                           ^
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/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from vault.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:
vault.cpp:73:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   73 |             ans = max(ans, dp2[i] + dp1[j]);
      |                                           ^