Submission #27736

#TimeUsernameProblemLanguageResultExecution timeMemory
27736top34051Brunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
413 ms80536 KiB
#include<bits/stdc++.h>
using namespace std;
#define inf (int)1e6
int n,m;
int p[100005];
int mx[10000005];
int mem[10000005];
main() {
    int i,j,x,val,ok;
    long long mul;
    scanf("%d%d",&n,&m);
    ok = 0; mul = 1;
    for(i=1;i<=n;i++) {
        scanf("%d",&val);
        x = 0;
        while(x<=10000000) {
            mx[x] = max(mx[x],val);
            x += val;
        }
        mul *= val;
        if(mul>=10000000) ok = 1;
    }
    for(i=0,j=1;i<=10000000;i++) for(j=max(j,i+1);j<i+mx[i];j++) mem[j] = mem[i]+1;
    while(m--) {
        scanf("%d",&x);
        if(x>=mul && !ok) printf("oo\n");
        else printf("%d\n",mem[x]);
    }
}

Compilation message (stderr)

brunhilda.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
brunhilda.cpp: In function 'int main()':
brunhilda.cpp:11:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
brunhilda.cpp:14:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&val);
                         ^
brunhilda.cpp:25: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...