Submission #1087179

#TimeUsernameProblemLanguageResultExecution timeMemory
1087179StaheosBank (IZhO14_bank)C++14
0 / 100
1 ms432 KiB
#include <iostream> using namespace std; int main(){ int n, m; cin >> n >> m; auto a = new int[n]; auto b = new int[m]; auto dp = new int[1005]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < m; i++) {cin >> b[i];} for (int i = 1; i < 1005; i++) {dp[i] = -1;} dp[0] = 0; for (int i = 1; i < 1005; i++) { for (int j = 0; j < m; j++) { if (i < b[m]) { continue; } if (dp[i - b[m]] == -1) { continue; } if (dp[i] == -1) { dp[i] = dp[i - b[m]] + 1; } else if (dp[i] > dp[i - b[m]] + 1) { dp[i] = dp[i - b[m]] + 1; } } } for (int i = 0; i < n; i++) { cout << dp[a[i]] << '\n'; }}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...