Submission #994225

# Submission time Handle Problem Language Result Execution time Memory
994225 2024-06-07T09:28:27 Z faqinyeager Intercastellar (JOI22_ho_t1) C++17
100 / 100
366 ms 9300 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<ll> a, pw;

int main(){
    int n;
    cin >> n;
    a.resize(n), pw.resize(n, 1);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        while(a[i] % 2 == 0){
            a[i] /= 2;
            pw[i] *= 2;
        }
    }

    for(int i = 1; i < n; i++) pw[i] += pw[i - 1];
    //for(int i = 0; i < n; i++) cout << a[i] << ' '; cout << '\n';
    //for(int i = 0; i < n; i++) cout << pw[i] << ' '; cout << "\n\n";

    int Q;
    cin >> Q;
    while(Q--){
        ll c;
        cin >> c;
        int l = 0, r = n - 1;
        while(r - l > 1){
            int m = (l + r) / 2;
            if(pw[m] < c){
                l = m + 1; // pw[l] <= pw[m] <= c <= pw[r] 
            }else{
                r = m; // pw[l] < c < pw[m] <= pw[r]
            }
        }
        cout << ((c > pw[l]) ? a[l + 1] : a[l]) << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 70 ms 3420 KB Output is correct
4 Correct 203 ms 2348 KB Output is correct
5 Correct 296 ms 5472 KB Output is correct
6 Correct 143 ms 4180 KB Output is correct
7 Correct 276 ms 5456 KB Output is correct
8 Correct 295 ms 5568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 444 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 70 ms 3420 KB Output is correct
4 Correct 203 ms 2348 KB Output is correct
5 Correct 296 ms 5472 KB Output is correct
6 Correct 143 ms 4180 KB Output is correct
7 Correct 276 ms 5456 KB Output is correct
8 Correct 295 ms 5568 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 444 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 173 ms 3016 KB Output is correct
24 Correct 150 ms 5184 KB Output is correct
25 Correct 317 ms 8788 KB Output is correct
26 Correct 205 ms 5456 KB Output is correct
27 Correct 170 ms 5480 KB Output is correct
28 Correct 346 ms 9300 KB Output is correct
29 Correct 366 ms 8908 KB Output is correct
30 Correct 227 ms 3668 KB Output is correct
31 Correct 351 ms 9044 KB Output is correct