Submission #757438

#TimeUsernameProblemLanguageResultExecution timeMemory
757438dxz05Brunhilda’s Birthday (BOI13_brunhilda)C++17
20 / 100
15 ms1380 KiB
#pragma GCC optimize("Ofast,O3,unroll-loops") #pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define bpc(x) __builtin_popcount(x) #define bpcll(x) __builtin_popcountll(x) #define MP make_pair //#define endl '\n' mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); typedef long long ll; const int MOD = 1e9 + 7; const int N = 1e4 + 2; int dp[N]; int max_p[N]; void solve(){ int m, q; cin >> m >> q; vector<int> primes(m); for (int i = 0; i < m; i++) cin >> primes[i]; for (int p : primes){ for (int i = 0; i < N; i += p) max_p[i] = p; } fill(dp + 1, dp + N, 1e9); int l = 0, r = 0; int val = 0; while (r < N){ if (l > r) break; int nxt_r = r; for (int i = l; i <= r; i++){ dp[i] = val; int p = max_p[i]; if (p == 0) continue; nxt_r = max(nxt_r, i + p - 1); } nxt_r = min(nxt_r, N - 1); l = r + 1; r = nxt_r; val++; } while (q--){ int i; cin >> i; if (dp[i] != 1e9){ cout << dp[i] << "\n"; } else { cout << "oo\n"; } } } int main(){ clock_t startTime = clock(); ios_base::sync_with_stdio(false); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int test_cases = 1; // cin >> test_cases; for (int test = 1; test <= test_cases; test++){ // cout << (solve() ? "YES" : "NO") << endl; solve(); } #ifdef LOCAL cerr << "Time: " << int((double) (clock() - startTime) / CLOCKS_PER_SEC * 1000) << " ms" << endl; #endif return 0; }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:71:13: warning: unused variable 'startTime' [-Wunused-variable]
   71 |     clock_t startTime = clock();
      |             ^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...