답안 #824967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824967 2023-08-14T12:41:39 Z phoenix Intercastellar (JOI22_ho_t1) C++17
100 / 100
73 ms 10072 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';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 19 ms 4860 KB Output is correct
4 Correct 32 ms 2636 KB Output is correct
5 Correct 51 ms 6364 KB Output is correct
6 Correct 30 ms 4804 KB Output is correct
7 Correct 54 ms 6420 KB Output is correct
8 Correct 50 ms 6560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 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 0 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 19 ms 4860 KB Output is correct
4 Correct 32 ms 2636 KB Output is correct
5 Correct 51 ms 6364 KB Output is correct
6 Correct 30 ms 4804 KB Output is correct
7 Correct 54 ms 6420 KB Output is correct
8 Correct 50 ms 6560 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 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 0 ms 212 KB Output is correct
18 Correct 1 ms 324 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 28 ms 3284 KB Output is correct
24 Correct 32 ms 5816 KB Output is correct
25 Correct 65 ms 9664 KB Output is correct
26 Correct 41 ms 6208 KB Output is correct
27 Correct 37 ms 6156 KB Output is correct
28 Correct 73 ms 10072 KB Output is correct
29 Correct 70 ms 9580 KB Output is correct
30 Correct 39 ms 3968 KB Output is correct
31 Correct 72 ms 10044 KB Output is correct