Submission #31883

#TimeUsernameProblemLanguageResultExecution timeMemory
31883KanvieBrunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
479 ms79628 KiB
#include<stdio.h> #include<algorithm> using namespace std; const int M=10000000; int x,m,q,d[M+5],a[100001],b[M+5],p,pp,cnt; int main() { scanf("%d%d",&m,&q); for(int i=1;i<=m;++i)scanf("%d",&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&&i<=M) { if(d[i]!=0)pp=max(pp,i+d[i]-1); b[i]=cnt; if(i==p)break; i++; } if(i==pp)break; p=pp; ++cnt; } while(q--) { scanf("%d",&x); if(b[x]==0&&x!=0)printf("oo\n"); else printf("%d\n",b[x]); } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:8:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&m,&q);
                        ^
brunhilda.cpp:9:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=m;++i)scanf("%d",&a[i]);
                                           ^
brunhilda.cpp:27:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...