Submission #31879

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
318792017-09-11 08:38:05KanvieBrunhilda’s Birthday (BOI13_brunhilda)C++14
5.56 / 100
409 ms41468 KiB
#include<bits/stdc++.h>
using namespace std;
const int M=10000000;
int x,m,q,d[M+1],a[100001],mx,p,pp,cnt;
int main()
{
cin>>m>>q;
for(int i=1;i<=m;++i)cin>>a[i];
for(int i=1;i<=m;++i)
for(int j=0;j<=M;j+=a[i])d[j]=max(d[j],a[i]);
for(int i=0;i<=M;++i)
{
while(i<=p)
{
if(d[i]!=0)pp=max(pp,i+d[i]-1);
d[i]=cnt;
if(i==p)break;
i++;
}
if(i==pp){mx=i;break;}
p=pp;
++cnt;
}
while(q--)
{
cin>>x;
if(mx<x)cout<<"oo\n";
else cout<<d[x]<<"\n";
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...