Submission #239420

#TimeUsernameProblemLanguageResultExecution timeMemory
239420luciocfBrunhilda’s Birthday (BOI13_brunhilda)C++14
0 / 100
334 ms42232 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5+10; const int maxv = 1e7+10; int p[maxn]; int dp[maxv]; int main(void) { int n, q; scanf("%d %d", &n, &q); int prod = 1; for (int i = 0; i < maxv; i++) dp[i] = 2*maxv; for (int i = 1; i <= n; i++) { scanf("%d", &p[i]); if (prod != maxv) { if (1ll*prod*p[i] > 1ll*maxv) prod = maxv; else prod *= p[i]; } for (int j = 0; j < maxv; j += p[i]) { int a = min(maxv-1, j+p[i]-1); dp[a] = min(dp[a], j); } } for (int i = maxv-2; i >= 0; i--) dp[i] = min(dp[i], dp[i+1]); while (q--) { int x; scanf("%d", &x); if (prod <= x) { printf("oo\n"); continue; } printf("%d\n", dp[x]); } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~~
brunhilda.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &p[i]);
   ~~~~~^~~~~~~~~~~~~
brunhilda.cpp:49:8: 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...