제출 #923728

#제출 시각아이디문제언어결과실행 시간메모리
923728shahd_abbaraIntercastellar (JOI22_ho_t1)C++17
100 / 100
61 ms9552 KiB

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define what(x) cout << (#x) << " -> " << x << '\n';
#define endl '\n'
#define cno cout << "NO" \
                 << "\n"
#define cy cout << "YES" \
                << "\n"
#define c1 cout << "-1" << '\n'
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

const ll N = 1000005;
const ll mod = 1000000007;

ll n, m, k, l, r, q, d, x, y, z, id, ind, pointer, point, next, curr, temp;
ll mn = 2e18, mx = 0, Maxmx = 0, Ans = 0, cost = 0, prod = 1, tot = 0, sum = 0;
ll a[N], arr[N], b[N];
vector<ll> v;
string s, t;

void solve()
{
    cin >> n;
    x = 1;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    ll ans[n + 4], ind[n + 4];
    for (int i = 1; i <= n; i++)
    {
        x = a[i];
        for (int j = 0; j <= 31; j++)
        {
            if (x & 1)
            {
                ans[i] = x;
                ind[i] = (1 << j);
                break;
            }
            x /= 2;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        sum += ind[i];
        ind[i] = sum;
    }

    cin >> q;
    while (q--)
    {
        cin >> m;
        x = lower_bound(ind + 1, ind + n + 1, m) - ind;

        cout << ans[x] << endl;
    }
}
int main()
{
    IOS int testcases = 1;

    // cin >> testcases;
    while (testcases--)
    {

        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...