Submission #1092634

#TimeUsernameProblemLanguageResultExecution timeMemory
1092634ortsacIntercastellar (JOI22_ho_t1)C++17
100 / 100
142 ms15444 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<long long, long long> #define fr first #define se second int32_t main() { int n; cin >> n; vector<int> v(n); vector<pii> g(n); for (int i = 0; i < n; i++) { cin >> v[i]; int qtd = 1; while (!(v[i] & 1LL)) { v[i] >>= 1; qtd <<= 1; } g[i] = {v[i], qtd}; } int q; cin >> q; vector<pii> queries(q); for (int i = 0; i < q; i++) { int x; cin >> x; queries[i] = {x, i}; } sort(queries.begin(), queries.end(), greater<pii>()); vector<int> ans(q); int qtd = 0; for (int i = 0; i < n; i++) { qtd += g[i].se; while (!queries.empty() && (qtd >= queries.back().fr)) { ans[queries.back().se] = g[i].fr; queries.pop_back(); } } for (auto u : ans) cout << u << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...