Submission #159753

#TimeUsernameProblemLanguageResultExecution timeMemory
159753Rouge_HugoBrunhilda’s Birthday (BOI13_brunhilda)C++14
5.56 / 100
1087 ms1524 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<<"00"<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...