Task: | Mastot |
Sender: | Tume7 |
Submission time: | 2019-10-12 04:36:02 +0300 |
Language: | C++ (C++17) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'long long int FindMinimumCost(long long int, long int*, long long int, long long int*, long long int*)': input/code.cpp:22:61: error: no matching function for call to 'min(int&, long long int)' n, kantamat, dp)); ^ 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 input/code.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: input/code.cpp:22:61: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')...
Code
#include <bits/stdc++.h> using namespace std; long long FindMinimumCost(long long ind, long hinnat[], long long n, long long kantamat[], long long dp[]) { if (ind == n) return 0; else if (dp[ind] != -1) return dp[ind]; else { int ans = INT_MAX; for (long long i = 1; i <= kantamat[ind]; i++) { if (ind + i <= n) ans = min(ans, hinnat[ind+i] + FindMinimumCost(ind + i, hinnat, n, kantamat, dp)); else break; } return dp[ind] = ans; } } int main() { long long kantamat[200001]; long long hinnat[200001]; long long n; cin >> n; for(long long i=0; i<n; i++){ cin>>kantamat[i]; } for(long long i=1; i<n; i++){ cin>>hinnat[i]; } hinnat[0] = 0; hinnat[n] = 0; kantamat[n] = 1; long long dp[n]; memset(dp, -1, sizeof dp); cout << FindMinimumCost(0, hinnat, n, kantamat, dp)<<"\n"; /* for(int i=0; i<=n; i++){ cout<<dp[i]<< " "; } cout<<"\n";*/ return 0; }