Submission #1109628

#TimeUsernameProblemLanguageResultExecution timeMemory
1109628qrnBrunhilda’s Birthday (BOI13_brunhilda)C++14
0 / 100
1093 ms1384 KiB
#include <bits/stdc++.h> using namespace std; #define SPEED ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); #define int long long // #define endl "\n" #define ALL(X) X.begin(), X.end() const int sz = 10005, inf = 1e9; vector<int>dp(sz, inf); void solve() { int m, Q; cin >> m >> Q; vector<int> p(m); for(int i = 0; i < m; i++) cin >> p[i]; dp[0] = 0; for(int i = 1; i <= sz; i++) { int mini = inf; for(int j = 0; j < m; j++) { mini = min(mini, dp[i - (i % p[j])]); } dp[i] = mini + 1; } // for(int i = 0; i <= 10; i++) { // cout << dp[i] << " "; // } // cout << endl; while(Q--) { int q; cin >> q; if(dp[q] == inf + 1) { cout << "oo" << endl; } else { cout << dp[q] << endl; } } } signed main() { SPEED; int tst = 1; // cin >> tst; for(int cs = 1; cs <= tst; cs++) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...