답안 #781185

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781185 2023-07-12T21:41:21 Z raphaelp Intercastellar (JOI22_ho_t1) C++14
100 / 100
380 ms 9164 KB
#include <bits/stdc++.h>
using namespace std;
int dico(int l, int r, long long val)
{
    long long mil = (l + r) / 2;
    if (mil == l)
        return l;
    mil = (1 << mil);
    if (val % mil == 0)
    {
        return dico((l + r) / 2, r, val);
    }
    else
        return dico(l, (l + r) / 2, val);
}
int dico2(int l, int r, long long val, vector<long long> &len)
{
    long long mil = (l + r) / 2;
    if (mil == l)
        if (val > len[mil])
            return r;
        else
            return l;
    if (val > len[mil])
    {
        return dico2((l + r) / 2, r, val, len);
    }
    else
        return dico2(l, (l + r) / 2, val, len);
}
int main()
{
    int N;
    cin >> N;
    vector<long long> value(N);
    vector<long long> len(N, 1);
    for (int i = 0; i < N; i++)
    {
        cin >> value[i];
        long long dec = dico(0, 31, value[i]);
        dec = (1 << dec);
        value[i] /= dec;
        len[i] *= dec;
    }
    for (int i = 1; i < N; i++)
    {
        len[i] += len[i - 1];
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        long long x;
        cin >> x;
        cout << value[dico2(0, N, x, len)] << '\n';
    }
}

Compilation message

Main.cpp: In function 'int dico2(int, int, long long int, std::vector<long long int>&)':
Main.cpp:19:8: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   19 |     if (mil == l)
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 76 ms 3960 KB Output is correct
4 Correct 203 ms 2288 KB Output is correct
5 Correct 318 ms 5640 KB Output is correct
6 Correct 217 ms 4072 KB Output is correct
7 Correct 358 ms 5476 KB Output is correct
8 Correct 318 ms 5644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 76 ms 3960 KB Output is correct
4 Correct 203 ms 2288 KB Output is correct
5 Correct 318 ms 5640 KB Output is correct
6 Correct 217 ms 4072 KB Output is correct
7 Correct 358 ms 5476 KB Output is correct
8 Correct 318 ms 5644 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 173 ms 3024 KB Output is correct
24 Correct 164 ms 5184 KB Output is correct
25 Correct 346 ms 8788 KB Output is correct
26 Correct 206 ms 5476 KB Output is correct
27 Correct 209 ms 5524 KB Output is correct
28 Correct 375 ms 9164 KB Output is correct
29 Correct 364 ms 8616 KB Output is correct
30 Correct 234 ms 3704 KB Output is correct
31 Correct 380 ms 9036 KB Output is correct