Submission #31863

#TimeUsernameProblemLanguageResultExecution timeMemory
31863minhtung0404Brunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
436 ms80532 KiB
#include<bits/stdc++.h> const int N = 1e5 + 5; const int M = 1e7 + 5; const int inf = 1e9; using namespace std; int n, q, p[N], m, prime[M], ans[M], cnt = 1, ct; int main(){ scanf("%d%d", &n, &q); for (int i = 1; i <= n; i++) scanf("%d", &p[i]); for (int i = 1; i <= n; i++){ for (int j = 0; j < M; j+=p[i]) prime[j] = max(prime[j], p[i]); } ans[0] = 1; while(ct < M){ if (ans[ct] == 0) break; while(cnt < ct + prime[ct] && cnt < M) ans[cnt] = ans[ct] + 1, cnt++; ct++; } while(q--){ scanf("%d", &m); if (ans[m] == 0) printf("oo\n"); else printf("%d\n", ans[m]-1); } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:10:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &q);
                          ^
brunhilda.cpp:11:52: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
                                                    ^
brunhilda.cpp:22:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &m);
                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...