#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
#define int long long
#define sqrt sqrtl
using namespace std;
const long long oo = 1000000000000000000;
long long sum, ans = 0, mx = 0, mn = 1000000000, num, pos;
/*
ViHHiPuh
(( `'-""``""-'` ))
)-__-_.._-__-(
/ --- (o _ o) --- \
\ .-* ( .0. ) *-. /
_'-. ,_ '=' _, .-'_
/ `;#'#'# - #'#'#;` \
\_)) -----'#'----- ((_/
# --------- #
'# ------- ------ #'
/..-'# ------- #'-.\
_\...-\'# -- #'/-.../_
((____)- '#' -(____))
cout << fixed << setprecision(6) << x;
freopen ( "sum.in", "r", stdin )
*/
int n, a[ 200001 ], q, x, b[ 200001 ], p[ 200001 ];
main () {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for ( int i = 1; i <= n; i ++ ) {
cin >> a[ i ];
b[ i ] = 1;
while ( a[ i ] % 2 == 0 ) {
b[ i ] *= 2;
a[ i ] /= 2;
}
p[ i ] = p[ i - 1 ] + b[ i ];
}
cin >> q;
while ( q -- ) {
cin >> x;
int l, r, mid;
l = 1;
r = n;
while ( r > l ) {
mid = ( r + l ) / 2;
if ( p[ mid ] >= x )
r = mid;
else
l = mid + 1;
}
cout << a[ l ] << "\n";
}
}
Compilation message
Main.cpp:47:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
47 | main () {
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
21 ms |
5516 KB |
Output is correct |
4 |
Correct |
29 ms |
2752 KB |
Output is correct |
5 |
Correct |
51 ms |
7104 KB |
Output is correct |
6 |
Correct |
29 ms |
5376 KB |
Output is correct |
7 |
Correct |
51 ms |
7092 KB |
Output is correct |
8 |
Correct |
50 ms |
7180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
340 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 |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
21 ms |
5516 KB |
Output is correct |
4 |
Correct |
29 ms |
2752 KB |
Output is correct |
5 |
Correct |
51 ms |
7104 KB |
Output is correct |
6 |
Correct |
29 ms |
5376 KB |
Output is correct |
7 |
Correct |
51 ms |
7092 KB |
Output is correct |
8 |
Correct |
50 ms |
7180 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
328 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 |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 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 |
30 ms |
3268 KB |
Output is correct |
24 |
Correct |
37 ms |
6348 KB |
Output is correct |
25 |
Correct |
64 ms |
10256 KB |
Output is correct |
26 |
Correct |
44 ms |
6516 KB |
Output is correct |
27 |
Correct |
41 ms |
6704 KB |
Output is correct |
28 |
Correct |
84 ms |
10780 KB |
Output is correct |
29 |
Correct |
74 ms |
10180 KB |
Output is correct |
30 |
Correct |
40 ms |
3952 KB |
Output is correct |
31 |
Correct |
79 ms |
10688 KB |
Output is correct |