Submission #334737

#TimeUsernameProblemLanguageResultExecution timeMemory
334737FischerBrunhilda’s Birthday (BOI13_brunhilda)C++14
80.32 / 100
313 ms80492 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e7 + 10; int dp[maxn]; int link[maxn]; int main() { int m, q; scanf("%d%d", &m, &q); for (int i=0; i<m; ++i) { int x; scanf("%d", &x); for (int j=x-1; j<maxn; j+=x) { link[j] = x-1; } } for (int i = maxn-2; i >= 1; --i) { if (link[i] < link[i+1] - 1) { link[i] = link[i+1] - 1; } } const int inf = 1e9; for (int i = 1; i < maxn; ++i) { if (link[i] == 0) dp[i] = inf; else dp[i] = min(inf, dp[i - link[i]] + 1); } while (q--) { int n; scanf("%d", &n); if (dp[n] > n) puts("oo\n"); else printf("%d\n", dp[n]); } return 0; }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  scanf("%d%d", &m, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~
brunhilda.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |   scanf("%d", &x);
      |   ~~~~~^~~~~~~~~~
brunhilda.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...