Submission #849977

# Submission time Handle Problem Language Result Execution time Memory
849977 2023-09-15T15:15:57 Z Ahmed57 Uplifting Excursion (BOI22_vault) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
int dp[2][505000*2+1],arr[301],br = 505000,n,m;

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>m>>n;
    for(int i = 0;i<2*m+1;i++){
        cin>>arr[i];
    }
    for(int i = 2*m+1;i>=0;i--){
        for(int j = 0;j<=505000*2;j++){
            if(i==2*m+1){
                if(j==n+br){
                    dp[i&1][j] = 0;
                }else{
                    dp[i&1][j] = -1e9;
                }
                continue;
            }
            long long ans = -1e9;
            for(int e = 0;e<=arr[i];e++){
                if(j+e*(i-m)<0||j+e*(i-m)>505000*2)continue;
                ans = max(ans,dp[!(i&1)][j+e*(i-m)]+e);
            }
            dp[i&1][j] = ans;
        }
    }
    long long vl = dp[0][505000];
    if(vl<0)cout<<"impossible\n";
    else cout<<vl<<endl;
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:24:54: error: no matching function for call to 'max(long long int&, int)'
   24 |                 ans = max(ans,dp[!(i&1)][j+e*(i-m)]+e);
      |                                                      ^
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 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:24:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 |                 ans = max(ans,dp[!(i&1)][j+e*(i-m)]+e);
      |                                                      ^
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 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:24:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 |                 ans = max(ans,dp[!(i&1)][j+e*(i-m)]+e);
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from vault.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:
vault.cpp:24:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |                 ans = max(ans,dp[!(i&1)][j+e*(i-m)]+e);
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from vault.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:
vault.cpp:24:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |                 ans = max(ans,dp[!(i&1)][j+e*(i-m)]+e);
      |                                                      ^