Submission #318120

#TimeUsernameProblemLanguageResultExecution timeMemory
318120shivensinha4Brunhilda’s Birthday (BOI13_brunhilda)C++17
100 / 100
721 ms158692 KiB
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include "bits/stdc++.h" using namespace std; #define for_(i, s, e) for (int i = s; i < (int) e; i++) #define for__(i, s, e) for (ll i = s; i < e; i++) typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; #define endl '\n' const int MXN = 2e7; int jmp[MXN+2], ans[MXN+2]; int main() { #ifdef shiven freopen("test.in", "r", stdin); #endif ios_base::sync_with_stdio(false); cin.tie(0); int m, q; cin >> m >> q; for_(i, 0, m) { int k; cin >> k; for (int j = k; j <= MXN; j += k) { jmp[j-1] = max(jmp[j-1], k-1); } } for (int i = MXN; i >= 1; i--) jmp[i] = max(jmp[i], jmp[i+1]-1); for_(i, 1, MXN+1) if (jmp[i] and (ans[i-jmp[i]] or i == jmp[i])) ans[i] = ans[i-jmp[i]]+1; for_(i, 0, q) { int k; cin >> k; if (ans[k]) cout << ans[k]; else cout << "oo"; cout << endl; } return 0; }

Compilation message (stderr)

brunhilda.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
brunhilda.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...