Submission #159754

#TimeUsernameProblemLanguageResultExecution timeMemory
159754Rouge_HugoBrunhilda’s Birthday (BOI13_brunhilda)C++14
5.56 / 100
1091 ms1812 KiB
#include <bits/stdc++.h> using namespace std; int n,q; int a[100009]; int main() { cin>>n>>q; for(int i=0;i<n;i++)cin>>a[i]; sort(a,a+n); int x; while (q--) { cin>>x; int re=0; bool r=0; for(int i=n-1;i>-1;i--) { if (x<a[n-1]) { r=1; cout<<re+1; break; } if (x==0) { r=1; cout<<re<<endl;break; } if (x%a[i]!=0){x=x-(x%a[i]); re++;} } if (r==0&&x<a[n-1]) cout<<re+1<<endl; else if (r==0)cout<<"oo"<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...