Submission #535231

#TimeUsernameProblemLanguageResultExecution timeMemory
535231MKutayBozkurtBrunhilda’s Birthday (BOI13_brunhilda)C++14
77.46 / 100
333 ms158276 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, q; cin >> n >> q; vector<int> a(n), d((int) 1e7 + 7), dp((int) 1e7 + 7, 1e9); for (int &x : a) { cin >> x; for (int i = x - 1; i <= 1e7; i += x) { d[i] = x - 1; } } for (int i = 1e7; i > 0; i--) d[i] = max(d[i], d[i + 1] - 1); dp[0] = 0; for (int i = 1; i <= 1e7; i++) { dp[i] = dp[i - d[i]] + 1; } while (q--) { int x; cin >> x; cout << (dp[x] >= 1e9 ? "oo" : to_string(dp[x])) << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...