Submission #1116474

# Submission time Handle Problem Language Result Execution time Memory
1116474 2024-11-21T17:07:12 Z heey Intercastellar (JOI22_ho_t1) C++14
100 / 100
143 ms 14888 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    //ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int q; cin >> q;
    vector<int> query(q);
    for(int i = 0; i < q; i++) cin >> query[i];

    vector<pair<int,int>> w;
    for(int i = 0; i < n; i++){

        if(a[i] % 2 != 0) w.emplace_back(a[i], 1);
        else {
            int t = 1;
            while(a[i] % 2 == 0){
                a[i] /= 2;
                t <<= 1;
            }
            w.emplace_back(a[i], t);
        }
    }

    vector<int> pr(w.size());
    pr[0] = w[0].second;
    for(int i = 1; i < n; i++) pr[i] = pr[i-1] + w[i].second;


    for(int i = 0; i < q; i++){
        int pos = lower_bound(pr.begin(), pr.end(), query[i]) - pr.begin();
        cout << w[pos].first << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 35 ms 9076 KB Output is correct
4 Correct 83 ms 4412 KB Output is correct
5 Correct 72 ms 11452 KB Output is correct
6 Correct 48 ms 9656 KB Output is correct
7 Correct 72 ms 11340 KB Output is correct
8 Correct 73 ms 11448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 480 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 35 ms 9076 KB Output is correct
4 Correct 83 ms 4412 KB Output is correct
5 Correct 72 ms 11452 KB Output is correct
6 Correct 48 ms 9656 KB Output is correct
7 Correct 72 ms 11340 KB Output is correct
8 Correct 73 ms 11448 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 480 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 49 ms 4552 KB Output is correct
24 Correct 61 ms 10168 KB Output is correct
25 Correct 111 ms 14524 KB Output is correct
26 Correct 90 ms 8376 KB Output is correct
27 Correct 80 ms 10936 KB Output is correct
28 Correct 136 ms 14888 KB Output is correct
29 Correct 138 ms 14520 KB Output is correct
30 Correct 72 ms 5312 KB Output is correct
31 Correct 143 ms 14824 KB Output is correct