답안 #787122

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787122 2023-07-18T20:48:07 Z stefanneagu Intercastellar (JOI22_ho_t1) C++17
100 / 100
169 ms 12344 KB
#include <iostream>
#include <algorithm>
#define int long long

using namespace std;

const int nmax = 2e5 + 1;

struct numar {
    int val, i;
} ax[nmax];

bool cmp(numar a, numar b) {
    return a.val < b.val;
}

int check(int x) {
    int cnt = 0;
    while(x % 2 == 0) {
        cnt ++;
        x /= 2;
    }
    return cnt;
}

int ans[nmax], v[nmax];

int32_t main() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        cin >> v[i];
    }
    int q;
    cin >> q;
    for(int i = 1; i <= q; i ++) {
        cin >> ax[i].val;
        ax[i].i = i;
    }
    sort(ax + 1, ax + q + 1, cmp);
    int curr = 0, ult = 0, an = 1;
    for(int i = 1; i <= n; i ++) {
        if(an == q + 1) {
            break;
        }
        ult = curr;
        curr ++;
        ult ++;
        int x = check(v[i]);
        curr += (1 << x) - 1;
        if(ult <= ax[an].val && ax[an].val <= curr) {
            ans[ax[an].i] = v[i] / (1 << x);
            an ++;
            i --;
            curr -= (1 << x);
            ult --;
        } 
    }
    for(int i = 1; i <= q; i ++) {
        cout << ans[i] << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 33 ms 2644 KB Output is correct
4 Correct 53 ms 4460 KB Output is correct
5 Correct 84 ms 6944 KB Output is correct
6 Correct 49 ms 3976 KB Output is correct
7 Correct 85 ms 6892 KB Output is correct
8 Correct 104 ms 6940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 212 KB Output is correct
7 Correct 1 ms 212 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 340 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 33 ms 2644 KB Output is correct
4 Correct 53 ms 4460 KB Output is correct
5 Correct 84 ms 6944 KB Output is correct
6 Correct 49 ms 3976 KB Output is correct
7 Correct 85 ms 6892 KB Output is correct
8 Correct 104 ms 6940 KB Output is correct
9 Correct 0 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 212 KB Output is correct
15 Correct 1 ms 212 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 340 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 50 ms 5576 KB Output is correct
24 Correct 69 ms 6036 KB Output is correct
25 Correct 126 ms 11876 KB Output is correct
26 Correct 90 ms 7152 KB Output is correct
27 Correct 85 ms 6400 KB Output is correct
28 Correct 158 ms 12344 KB Output is correct
29 Correct 169 ms 11800 KB Output is correct
30 Correct 83 ms 7128 KB Output is correct
31 Correct 163 ms 12156 KB Output is correct