Submission #318115

#TimeUsernameProblemLanguageResultExecution timeMemory
318115shivensinha4Brunhilda’s Birthday (BOI13_brunhilda)C++17
97.78 / 100
694 ms157540 KiB
#include "bits/stdc++.h" using namespace std; #define for_(i, s, e) for (int i = s; i < (int) e; i++) #define for__(i, s, e) for (ll i = s; i < e; i++) typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; #define endl '\n' const int MXN = (1e7)+9999992; int jmp[MXN+2], ans[MXN+2]; int main() { #ifdef shiven freopen("test.in", "r", stdin); #endif ios_base::sync_with_stdio(false); cin.tie(0); int m, q; cin >> m >> q; for_(i, 0, m) { int k; cin >> k; for (int j = k; j <= MXN; j += k) { jmp[j-1] = max(jmp[j-1], k-1); } } for (int i = MXN; i >= 0; i--) jmp[i] = max(jmp[i], jmp[i+1]-1); for_(i, 1, MXN+1) if (jmp[i]) ans[i] = ans[i-jmp[i]]+1; for_(i, 0, q) { int k; cin >> k; if (ans[k]) cout << ans[k]; else cout << "oo"; cout << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...