#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define SZ(x) ((int)((x).size()))
#define pow2(x) ((ll)(x) * (x))
const ll mod = 1e9 + 7;
const int INF = 1e9 + 5; // 998244353
const ll INFF = 1e18 + 5;
// Super is the cutest girl
void solve()
{
int n;
cin >> n;
vl v(n);
for (int i = 0; i < n; i++)
{
cin >> v[i];
}
vl pos;
int q;
cin >> q;
ll curr = 1;
vl val;
for (int i = 0; i < n; i++)
{
pos.pb(curr);
ll cnt = 1;
while (v[i] % 2 == 0)
{
cnt *= 2;
v[i] /= 2;
}
val.pb(v[i]);
curr += cnt;
}
while (q--)
{
ll x;
cin >> x;
int valpos = upper_bound(all(pos), x) - pos.begin();
valpos--;
cout << val[valpos] << '\n';
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// int t; cin >> t; while(t--)
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
21 ms |
5828 KB |
Output is correct |
4 |
Correct |
16 ms |
3024 KB |
Output is correct |
5 |
Correct |
38 ms |
7356 KB |
Output is correct |
6 |
Correct |
21 ms |
5576 KB |
Output is correct |
7 |
Correct |
29 ms |
7360 KB |
Output is correct |
8 |
Correct |
29 ms |
7356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
21 ms |
5828 KB |
Output is correct |
4 |
Correct |
16 ms |
3024 KB |
Output is correct |
5 |
Correct |
38 ms |
7356 KB |
Output is correct |
6 |
Correct |
21 ms |
5576 KB |
Output is correct |
7 |
Correct |
29 ms |
7360 KB |
Output is correct |
8 |
Correct |
29 ms |
7356 KB |
Output is correct |
9 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
15 ms |
3544 KB |
Output is correct |
24 |
Correct |
25 ms |
6472 KB |
Output is correct |
25 |
Correct |
60 ms |
10672 KB |
Output is correct |
26 |
Correct |
43 ms |
6848 KB |
Output is correct |
27 |
Correct |
38 ms |
6920 KB |
Output is correct |
28 |
Correct |
45 ms |
10936 KB |
Output is correct |
29 |
Correct |
42 ms |
10416 KB |
Output is correct |
30 |
Correct |
32 ms |
4288 KB |
Output is correct |
31 |
Correct |
44 ms |
10932 KB |
Output is correct |