Submission #156364

# Submission time Handle Problem Language Result Execution time Memory
156364 2019-10-05T11:13:12 Z brcode Journey (NOI18_journey) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>

using namespace std;
const int MAXN = 1010;
long long dp[MAXN][MAXN];
vector<pair<int,int>> v1[MAXN];

int main(){
    int n,m,h;
    cin>>n>>m>>h;
    for(int i=1;i<n;i++){
        for(int j=1;j<=h;j++){
            int x,y;
            cin>>x>>y;
            v1[x+1].push_back(make_pair(i,y));
            if(i==1){
                dp[x+1][y]++;
            }
        }
    }
    for(int i=2;i<=n;i++){
        for(int k=0;k<=m;k++){
            if(k){
                dp[i][k] += dp[i][k-1];
            }
            for(auto x:v1[i]){
               if(k-x.second>=0 && x.first!=1){
                    dp[i][k]+=dp[x.first][k-x.second];
                    dp[i][k] = min(dp[i][k],500000000);
               }
            }
        }
    }
    for(int i=0;i<m;i++){
        cout<<dp[n][i]<<" ";
    }
}

Compilation message

journey.cpp: In function 'int main()':
journey.cpp:30:54: error: no matching function for call to 'min(long long int&, int)'
                     dp[i][k] = min(dp[i][k],500000000);
                                                      ^
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/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from journey.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:
journey.cpp:30:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
                     dp[i][k] = min(dp[i][k],500000000);
                                                      ^
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/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from journey.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:
journey.cpp:30:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
                     dp[i][k] = min(dp[i][k],500000000);
                                                      ^