Submission #209935

#TimeUsernameProblemLanguageResultExecution timeMemory
209935dantoh000Brunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
332 ms87800 KiB
#include <bits/stdc++.h> using namespace std; const int INF = 1000000007; const int MAXN = 11000000; int a[MAXN]; int ans[MAXN]; int main(){ int n,q; scanf("%d%d",&n,&q); for (int i = 0; i < n; i++){ int k; scanf("%d",&k); for (int j = k-1; j < MAXN; j+=k){ a[j] = k-1; } } for (int i = MAXN-2; i >= 0; i--){ a[i] = max(a[i],a[i+1]-1); } fill(ans,ans+MAXN,INF); ans[1] = 1; ans[0] = 0; for (int i = 2; i < MAXN; i++){ if (a[i] == 0) ans[i] = INF; else ans[i] = min(ans[i],ans[i-a[i]]+1); } for (int i = 0; i < q; i++){ int x; scanf("%d",&x); if (ans[x] == INF) printf("oo\n"); else printf("%d\n",ans[x]); } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&q);
     ~~~~~^~~~~~~~~~~~~~
brunhilda.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
         ~~~~~^~~~~~~~~
brunhilda.cpp:29:14: 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...