Submission #923728

# Submission time Handle Problem Language Result Execution time Memory
923728 2024-02-07T16:25:03 Z shahd_abbara Intercastellar (JOI22_ho_t1) C++17
100 / 100
61 ms 9552 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define what(x) cout << (#x) << " -> " << x << '\n';
#define endl '\n'
#define cno cout << "NO" \
                 << "\n"
#define cy cout << "YES" \
                << "\n"
#define c1 cout << "-1" << '\n'
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

const ll N = 1000005;
const ll mod = 1000000007;

ll n, m, k, l, r, q, d, x, y, z, id, ind, pointer, point, next, curr, temp;
ll mn = 2e18, mx = 0, Maxmx = 0, Ans = 0, cost = 0, prod = 1, tot = 0, sum = 0;
ll a[N], arr[N], b[N];
vector<ll> v;
string s, t;

void solve()
{
    cin >> n;
    x = 1;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    ll ans[n + 4], ind[n + 4];
    for (int i = 1; i <= n; i++)
    {
        x = a[i];
        for (int j = 0; j <= 31; j++)
        {
            if (x & 1)
            {
                ans[i] = x;
                ind[i] = (1 << j);
                break;
            }
            x /= 2;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        sum += ind[i];
        ind[i] = sum;
    }

    cin >> q;
    while (q--)
    {
        cin >> m;
        x = lower_bound(ind + 1, ind + n + 1, m) - ind;

        cout << ans[x] << endl;
    }
}
int main()
{
    IOS int testcases = 1;

    // cin >> testcases;
    while (testcases--)
    {

        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 17 ms 7640 KB Output is correct
4 Correct 23 ms 3416 KB Output is correct
5 Correct 40 ms 7920 KB Output is correct
6 Correct 23 ms 7260 KB Output is correct
7 Correct 40 ms 8272 KB Output is correct
8 Correct 40 ms 7940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 17 ms 7640 KB Output is correct
4 Correct 23 ms 3416 KB Output is correct
5 Correct 40 ms 7920 KB Output is correct
6 Correct 23 ms 7260 KB Output is correct
7 Correct 40 ms 8272 KB Output is correct
8 Correct 40 ms 7940 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 21 ms 4188 KB Output is correct
24 Correct 26 ms 7628 KB Output is correct
25 Correct 50 ms 9552 KB Output is correct
26 Correct 34 ms 6988 KB Output is correct
27 Correct 32 ms 7252 KB Output is correct
28 Correct 61 ms 8788 KB Output is correct
29 Correct 56 ms 8016 KB Output is correct
30 Correct 30 ms 3416 KB Output is correct
31 Correct 59 ms 8420 KB Output is correct