Submission #703571

#TimeUsernameProblemLanguageResultExecution timeMemory
703571Jeff12345121Intercastellar (JOI22_ho_t1)C++14
0 / 100
46 ms7776 KiB
#include <bits/stdc++.h> #define int long long using namespace std; #ifdef LOCAL ifstream in("in.in"); ofstream out("out.out"); #else #define in cin #define out cout #endif const int nmax = 200005; int n,a[nmax],q,nr[nmax],val[nmax]; pair<int,int> get_nr(int x) { int nr = 1; while(x%2 == 0) { nr = nr * 2; x /= 2; } return {nr,x}; } pair<int,int> qs[nmax]; int sol[nmax]; int32_t main() { in >> n; for (int i = 1; i <= n; i++) { in >> a[i]; } for (int i = 1; i <= n; i++) { auto v = get_nr(a[i]); nr[i] = v.first; val[i] = v.second; nr[i] += nr[i - 1]; } in >> q; for (int i = 1; i <= q; i++) { int x; in >> x; qs[i] = {x, i}; } sort(qs + 1, qs + 1 + n); for (int i = 1; i <= q; i++) { for (int j = 1; j <= n; j++) { if (nr[j] >= qs[i].first) { sol[qs[i].second] = val[j]; break; } } } for (int i = 1; i <= q; i++) { out << sol[i] << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...