Submission #1015947

#TimeUsernameProblemLanguageResultExecution timeMemory
1015947caterpillowBrunhilda’s Birthday (BOI13_brunhilda)C++17
61.43 / 100
1098 ms43472 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pl = pair<ll, ll>; using pi = pair<int, int>; #define vt vector #define f first #define s second #define pb push_back #define all(x) x.begin(), x.end() #define size(x) ((int) (x).size()) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--) #define F0R(i, b) FOR (i, 0, b) #define endl '\n' const ll INF = 1e18; const int inf = 1e9; template<template<typename> class Container, typename T> ostream& operator<<(ostream& os, Container<T> o) { os << "{"; int g = size(o); for (auto i : o) os << i << ((--g) == 0 ? "" : ", "); os << "}"; return os; } void _print() { cerr << "\n"; } template<typename T, typename ...V> void _print(T t, V... v) { cerr << t; if (sizeof...(v)) cerr << ", "; _print(v...); } #ifdef LOCAL #define dbg(x...) cerr << #x << " = "; _print(x); #else #define dbg(x...) #define cerr if (0) std::cerr #endif const int maxn = 1e7 + 1; int m, qs; int dp[maxn]; vt<int> primes, ans; vt<pi> queries; priority_queue<pi, vt<pi>, greater<pi>> q; main() { cin.tie(0)->sync_with_stdio(0); cin >> m >> qs; primes.resize(m); F0R (i, m) cin >> primes[i]; for (int p : primes) q.push({0, p}); queries.resize(qs); F0R (i, qs) cin >> queries[i].f, queries[i].s = i; sort(all(queries)); reverse(all(queries)); ans.resize(qs, -1); FOR (i, 1, maxn) { while (q.top().f + q.top().s <= i) { q.push({q.top().f + q.top().s, q.top().s}); q.pop(); } if (q.top().f == i) break; dp[i] = dp[q.top().f] + 1; while (size(queries) && queries.back().f == i) { ans[queries.back().s] = dp[i]; queries.pop_back(); } if (!size(q)) break; } F0R (i, qs) { if (ans[i] == -1) cout << "oo\n"; else cout << ans[i] << endl; } }

Compilation message (stderr)

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