제출 #586501

#제출 시각아이디문제언어결과실행 시간메모리
586501TheEvilBirdIntercastellar (JOI22_ho_t1)C++17
100 / 100
85 ms9248 KiB
#include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <numeric>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <ctime>
#include <chrono>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
//typedef __int128_t int128;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const char en = '\n';
const int INF = 1e9 + 7;
const ll INFLL = 1e18;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

void solve() {
    int n;
    cin >> n;
    vector<pair<int, ll>> a;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        int p = 0;
        while (x % 2 == 0) {
            ++p;
            x /= 2;
        }
        if (a.empty() || a.back().first != x) {
            a.emplace_back(x, 0);
        }
        if (x == a.back().first) {
            a.back().second += (1LL << p);
        }
    }
    int q;
    cin >> q;
    int ptr = -1;
    ll sum = 0;
    while (q--) {
        ll i;
        cin >> i;
        while (i > sum) {
            ++ptr;
            sum += a[ptr].second;
        }
        cout << a[ptr].first << en;
    }
}

int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    solve();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...