Submission #781180

# Submission time Handle Problem Language Result Execution time Memory
781180 2023-07-12T21:21:12 Z raphaelp Intercastellar (JOI22_ho_t1) C++14
25 / 100
309 ms 5580 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++)
    {
        int 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)
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 76 ms 3972 KB Output is correct
4 Correct 206 ms 2320 KB Output is correct
5 Correct 297 ms 5508 KB Output is correct
6 Correct 148 ms 4060 KB Output is correct
7 Correct 309 ms 5472 KB Output is correct
8 Correct 306 ms 5580 KB Output is correct
# Verdict Execution time Memory 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 1 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 76 ms 3972 KB Output is correct
4 Correct 206 ms 2320 KB Output is correct
5 Correct 297 ms 5508 KB Output is correct
6 Correct 148 ms 4060 KB Output is correct
7 Correct 309 ms 5472 KB Output is correct
8 Correct 306 ms 5580 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 1 ms 212 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Incorrect 1 ms 212 KB Output isn't correct
18 Halted 0 ms 0 KB -