Submission #559463

#TimeUsernameProblemLanguageResultExecution timeMemory
559463TrunktyBrunhilda’s Birthday (BOI13_brunhilda)C++14
0 / 100
230 ms262144 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; #define DEBUG #ifdef DEBUG #define debug(x) cout << #x << ": " << x << endl #else #define debug(x) #endif int m,q; vector<int> upd[10000005]; int cnt[10000005]; int curr[10000005]; int ans[10000005],lp=0,maxi=2e9; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> m >> q; for(int i=1;i<=m;i++){ int a; cin >> a; for(int j=a;j<=1e7;j+=a){ upd[j].push_back(a); } cnt[0]++; } for(int i=1;i<=1e7;i++){ for(int j:upd[i]){ cnt[curr[j]]--; curr[j] = i; cnt[curr[j]]++; } while(lp!=i and !cnt[lp]){ lp++; } if(lp==i){ maxi = i; break; } ans[i] = ans[lp]+1; } for(int i=1;i<=q;i++){ int a; cin >> a; if(a<maxi){ cout << ans[a] << "\n"; } else{ cout << "oo" << "\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...