Submission #30900

#TimeUsernameProblemLanguageResultExecution timeMemory
30900NavickBrunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
843 ms158268 KiB
#include <bits/stdc++.h> #define F first #define S second #define pii pair<int, int> #define pb push_back using namespace std; typedef long long ll; typedef long double ld; const int N = 1e7 + 10, INF = 1e9; int dp[N], p[N], rm[2 * N]; int main(){ int m, q; scanf("%d %d", &m, &q); for(int i=0; i<m; i++){ scanf("%d", p + i); for(int k=p[i] - 1; k<2 * N; k+=p[i]) rm[k] = p[i] - 1; } for(int i=2*N-1; i>=1; i--) rm[i] = max(rm[i], rm[i + 1] - 1); for(int i=1; i<N; i++){ if(rm[i] == 0){ break; }else{ dp[i] = dp[i - rm[i]] + 1; } } for(int i=0; i<q; i++){ int n; scanf("%d", &n); if(dp[n] == 0) printf("oo\n"); else printf("%d\n", dp[n]); } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:17:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int m, q; scanf("%d %d", &m, &q);
                                  ^
brunhilda.cpp:20:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", p + i);
                     ^
brunhilda.cpp:37:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int n; scanf("%d", &n);
                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...