Submission #784361

#TimeUsernameProblemLanguageResultExecution timeMemory
784361HanksburgerIntercastellar (JOI22_ho_t1)C++17
100 / 100
63 ms9344 KiB
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > vec;
long long a[200005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n, q;
    cin >> n;
    for (long long i=0; i<n; i++)
    {
        long long x, cnt=0;
        cin >> x;
        while (!(x&1))
        {
            cnt++;
            x>>=1;
        }
        vec.push_back({1<<cnt, x});
    }
    for (long long i=1; i<n; i++)
        vec[i].first+=vec[i-1].first;
    cin >> q;
    for (long long i=0; i<q; i++)
    {
        long long x;
        cin >> x;
        cout << (*lower_bound(vec.begin(), vec.end(), make_pair(x, 0LL))).second << '\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...