Submission #801051

# Submission time Handle Problem Language Result Execution time Memory
801051 2023-08-02T04:17:11 Z vjudge1 Intercastellar (JOI22_ho_t1) C++17
100 / 100
78 ms 10068 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    int a[n];
    vector<pair<int, int>> v;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        int x = a[i], k = 1;
        while(x % 2 == 0) {
            x /= 2;
            k *= 2;
        }
        v.push_back({x, k});
    } 
    ll sm[n];
    for(int i = 0; i < n; i++) 
        sm[i] = v[i].second + (i ? sm[i - 1] : 0);
    
    int q;
    cin >> q;
    while(q--) {
        ll x;
        cin >> x; 
        int lb = -1, rb = n;
        while(rb - lb > 1) {
            int mid = (lb + rb) / 2;
            if(sm[mid] < x) lb = mid;
            else rb = mid;
        }     
        if(rb == n) cout << -1;
        else cout << v[rb].first;
        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 18 ms 4812 KB Output is correct
4 Correct 32 ms 2668 KB Output is correct
5 Correct 51 ms 6384 KB Output is correct
6 Correct 30 ms 4804 KB Output is correct
7 Correct 52 ms 6464 KB Output is correct
8 Correct 52 ms 6464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 18 ms 4812 KB Output is correct
4 Correct 32 ms 2668 KB Output is correct
5 Correct 51 ms 6384 KB Output is correct
6 Correct 30 ms 4804 KB Output is correct
7 Correct 52 ms 6464 KB Output is correct
8 Correct 52 ms 6464 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 32 ms 3192 KB Output is correct
24 Correct 33 ms 5924 KB Output is correct
25 Correct 78 ms 9720 KB Output is correct
26 Correct 40 ms 6212 KB Output is correct
27 Correct 37 ms 6252 KB Output is correct
28 Correct 73 ms 10068 KB Output is correct
29 Correct 76 ms 9564 KB Output is correct
30 Correct 42 ms 3920 KB Output is correct
31 Correct 72 ms 10040 KB Output is correct