답안 #939580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939580 2024-03-06T14:30:57 Z TAhmed33 Intercastellar (JOI22_ho_t1) C++
100 / 100
65 ms 9340 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 25;
pair <ll, ll> a[MAXN];
int n, q;
void solve () {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		ll x; cin >> x;
		ll c = 0;
		while (!(x & 1)) {
			c++; x /= 2;
		}
		a[i] = {(1ll << c) + a[i - 1].first, x};
	}
	cin >> q;
	while (q--) {
		ll x; cin >> x;
		int l = 1, r = n, ans = -1;
		while (l <= r) {
			int mid = (l + r) / 2;
			if (a[mid].first >= x) {
				r = mid - 1; ans = mid;
			} else {
				l = mid + 1;
			}
		}
		cout << a[ans].second << '\n';
	}
}	
int main () {
	ios::sync_with_stdio(0); cin.tie(0);
	int t = 1; //cin >> t;
	while (t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 15 ms 3932 KB Output is correct
4 Correct 25 ms 3952 KB Output is correct
5 Correct 42 ms 5460 KB Output is correct
6 Correct 24 ms 3996 KB Output is correct
7 Correct 41 ms 5720 KB Output is correct
8 Correct 42 ms 5724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 516 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 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 15 ms 3932 KB Output is correct
4 Correct 25 ms 3952 KB Output is correct
5 Correct 42 ms 5460 KB Output is correct
6 Correct 24 ms 3996 KB Output is correct
7 Correct 41 ms 5720 KB Output is correct
8 Correct 42 ms 5724 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 516 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 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 23 ms 4700 KB Output is correct
24 Correct 34 ms 5264 KB Output is correct
25 Correct 55 ms 8784 KB Output is correct
26 Correct 37 ms 5792 KB Output is correct
27 Correct 37 ms 5712 KB Output is correct
28 Correct 62 ms 9340 KB Output is correct
29 Correct 59 ms 8836 KB Output is correct
30 Correct 34 ms 5716 KB Output is correct
31 Correct 65 ms 9296 KB Output is correct