Submission #1126016

#TimeUsernameProblemLanguageResultExecution timeMemory
1126016KasymKBrunhilda’s Birthday (BOI13_brunhilda)C++20
100 / 100
341 ms79248 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define pli pair<ll, int> #define pll pair<ll, ll> #define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i) #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int N = 1e5+5; const int M = 1e7+5; int p[N], ad[M], dp[M]; int main(){ // freopen("file.txt", "r", stdin); int m, q; scanf("%d%d", &m, &q); for(int i = 1; i <= m; ++i){ scanf("%d", p+i); for(int j = p[i]; j<M-3; j+=p[i]) ad[j-1]=p[i]-1; umax(ad[M-5], (M-5)%p[i]); } for(int i = M-5; i >= 1; --i) umax(ad[i], ad[i+1]-1); for(int i = 1; i < M-4; ++i){ dp[i]=dp[i-ad[i]]; if(ad[i]!=0 and ~dp[i]) dp[i]++; else dp[i]=-1; } while(q--){ int x; scanf("%d", &x); if(~dp[x]){ printf("%d\n", dp[x]); continue; } puts("oo"); } return 0; }

Compilation message (stderr)

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