제출 #1329866

#제출 시각아이디문제언어결과실행 시간메모리
1329866hoangtien69Intercastellar (JOI22_ho_t1)C++20
100 / 100
56 ms8640 KiB
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
#define pii pair<int,int>
#define int long long

int n;
int a[MAXN];
pii peal[MAXN];
int pre[MAXN];
int q;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++)
    {
        int cur = 1;
        while(a[i] % 2 == 0)
        {
            cur *= 2;
            a[i] /= 2;
        }
        peal[i].first = a[i];
        peal[i].second = cur;
    }
    for (int i = 1; i <= n; i++)
    {
        pre[i] = pre[i - 1] + peal[i].second;
    }
    cin >> q;
    while(q--)
    {
        int x;
        cin >> x;
        int pos = lower_bound(pre + 1, pre + n + 1, x) - pre;
        cout << peal[pos].first << "\n";
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...