답안 #886546

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886546 2023-12-12T09:56:14 Z dubabuba Intercastellar (JOI22_ho_t1) C++14
100 / 100
403 ms 10760 KB
#include <iostream>
using namespace std;

#define int long long
typedef pair<int, int> pii;
#define ff first
#define ss second
#define MP make_pair

const int mxl = 30;
const int mxn = 2e5 + 10;
int a[mxn], n, q;
pii p[mxn];

void build() {
	for(int i = 1; i <= n; i++) {
		const int &A = a[i];

		for(int k = 0; k < mxl; k++)
		if(A & (1LL << k)) {
			p[i].ff = (1LL << k);
			p[i].ss = (A >> k);
			break;
		}

		p[i].ff += p[i - 1].ff;
	}
}

int solve(int x) {
	auto it = lower_bound(p + 1, p + n + 1, MP(x, 0LL));
	return (*it).ss;
}

signed main() {
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];

	build();

	cin >> q;
	while(q--) {
		int x;
		cin >> x;
		cout << solve(x) << '\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 76 ms 5712 KB Output is correct
4 Correct 218 ms 5868 KB Output is correct
5 Correct 303 ms 7188 KB Output is correct
6 Correct 153 ms 5896 KB Output is correct
7 Correct 307 ms 7044 KB Output is correct
8 Correct 302 ms 7248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2496 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2504 KB Output is correct
8 Correct 2 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 4 ms 2396 KB Output is correct
12 Correct 3 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 2 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 76 ms 5712 KB Output is correct
4 Correct 218 ms 5868 KB Output is correct
5 Correct 303 ms 7188 KB Output is correct
6 Correct 153 ms 5896 KB Output is correct
7 Correct 307 ms 7044 KB Output is correct
8 Correct 302 ms 7248 KB Output is correct
9 Correct 1 ms 2392 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 2496 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2504 KB Output is correct
16 Correct 2 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 4 ms 2396 KB Output is correct
20 Correct 3 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 2 ms 2396 KB Output is correct
23 Correct 184 ms 6872 KB Output is correct
24 Correct 159 ms 7196 KB Output is correct
25 Correct 358 ms 10364 KB Output is correct
26 Correct 209 ms 7764 KB Output is correct
27 Correct 177 ms 7688 KB Output is correct
28 Correct 398 ms 10760 KB Output is correct
29 Correct 403 ms 10484 KB Output is correct
30 Correct 249 ms 7704 KB Output is correct
31 Correct 377 ms 10604 KB Output is correct