Submission #251982

#TimeUsernameProblemLanguageResultExecution timeMemory
251982abacabaBrunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
798 ms158056 KiB
#include <bits/stdc++.h> using namespace std; template <typename T> void Min(T &a, T b) { a = min(a, b); } template <typename T> void Max(T &a, T b) { a = max(a, b); } const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; const int N = 2e7 + 15; int m, q, mx[N], dp[N]; main() { memset(dp, 0x3f, sizeof(dp)); ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); cin >> m >> q; while(m--) { int p; cin >> p; for(int i = p - 1; i < N; i += p) Max(mx[i], p - 1); } for(int i = N - 2; i; --i) Max(mx[i], mx[i + 1] - 1); dp[0] = 0; for(int i = 1; i < N; ++i) Min(dp[i], dp[i - mx[i]] + 1); while(q--) { int x; cin >> x; if(dp[x] == inf) cout << "oo" << endl; else cout << dp[x] << endl; } return 0; }

Compilation message (stderr)

brunhilda.cpp:17:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...