답안 #783768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783768 2023-07-15T10:04:28 Z borisAngelov Intercastellar (JOI22_ho_t1) C++17
100 / 100
64 ms 9220 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 200005;

int n;

pair<int, long long> preffix[maxn];

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fastIO();

    cin >> n;

    for (int i = 1; i <= n; ++i)
    {
        int number;
        cin >> number;

        int new_number = number;

        while (new_number % 2 == 0)
        {
            new_number /= 2;
        }

        preffix[i].first = new_number;
        preffix[i].second = preffix[i - 1].second + number / new_number;
    }

    int q;
    cin >> q;

    for (int i = 1; i <= q; ++i)
    {
        long long x;
        cin >> x;

        int l = 1;
        int r = n;

        while (l <= r)
        {
            int mid = (l + r) / 2;

            if (x > preffix[mid].second)
            {
                l = mid + 1;
            }
            else
            {
                r = mid - 1;
            }
        }

        cout << preffix[l].first << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 17 ms 3924 KB Output is correct
4 Correct 26 ms 2312 KB Output is correct
5 Correct 43 ms 5452 KB Output is correct
6 Correct 24 ms 4092 KB Output is correct
7 Correct 42 ms 5548 KB Output is correct
8 Correct 41 ms 5588 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 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 336 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 212 KB Output is correct
10 Correct 1 ms 340 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 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 17 ms 3924 KB Output is correct
4 Correct 26 ms 2312 KB Output is correct
5 Correct 43 ms 5452 KB Output is correct
6 Correct 24 ms 4092 KB Output is correct
7 Correct 42 ms 5548 KB Output is correct
8 Correct 41 ms 5588 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 336 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 212 KB Output is correct
18 Correct 1 ms 340 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 24 ms 3048 KB Output is correct
24 Correct 29 ms 5148 KB Output is correct
25 Correct 58 ms 8680 KB Output is correct
26 Correct 37 ms 5496 KB Output is correct
27 Correct 35 ms 5528 KB Output is correct
28 Correct 63 ms 9220 KB Output is correct
29 Correct 61 ms 8604 KB Output is correct
30 Correct 33 ms 3660 KB Output is correct
31 Correct 64 ms 9152 KB Output is correct