Submission #283055

#TimeUsernameProblemLanguageResultExecution timeMemory
283055egekabasBrunhilda’s Birthday (BOI13_brunhilda)C++14
20 / 100
1099 ms1020 KiB
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<int, int> pii; typedef pair<ld, ld> pld; int n, q; int p[100009]; int ans[10000001]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); cin >> n >> q; for(int i = 0; i < n; ++i) cin >> p[i]; reverse(p, p+n); ans[0] = 0; int lim = 1e4+1; for(int i = 1; i < lim; ++i){ ans[i] = 1e9; for(int j = 0; j < n; ++j){ if(i%p[j] != 0){ ans[i] = min(ans[i], 1+ans[i-i%p[j]]); } } if(ans[i] == 1e9){ lim = i; break; } } while(q--){ int x; cin >> x; if(x >= lim) cout << "oo\n"; else cout << ans[x] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...