Submission #1032646

# Submission time Handle Problem Language Result Execution time Memory
1032646 2024-07-24T05:05:16 Z juicy Intercastellar (JOI22_ho_t1) C++17
100 / 100
69 ms 10180 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	function<int(int)> rec = [&](int x) {
		if (x & 1) {
			return 1;
		}
		return 2 * rec(x / 2);
	};
	vector<pair<int, long long>> B;
	for (int i = 0; i < N; ++i) {
		int x = A[i];
		while (x % 2 == 0) {
			x /= 2;
		}
		B.push_back({x, rec(A[i])});
	}
	for (int i = 1; i < N; ++i) {
		B[i].second += B[i - 1].second;
	}
	int Q; cin >> Q;
	while (Q--) {
		long long X; cin >> X;
		int L = 0, R = N - 1, res = -1;
		while (L <= R) {
			int md = (L + R) / 2;
			if (B[md].second >= X) {
				res = md;
				R = md - 1;
			} else {
				L = md + 1;
			}
		}
		cout << B[res].first << "\n";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 16 ms 6972 KB Output is correct
4 Correct 21 ms 1760 KB Output is correct
5 Correct 37 ms 5844 KB Output is correct
6 Correct 21 ms 6352 KB Output is correct
7 Correct 35 ms 5588 KB Output is correct
8 Correct 37 ms 5840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 1 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 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 460 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 16 ms 6972 KB Output is correct
4 Correct 21 ms 1760 KB Output is correct
5 Correct 37 ms 5844 KB Output is correct
6 Correct 21 ms 6352 KB Output is correct
7 Correct 35 ms 5588 KB Output is correct
8 Correct 37 ms 5840 KB Output is correct
9 Correct 1 ms 344 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 1 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 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 460 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 26 ms 3284 KB Output is correct
24 Correct 27 ms 6608 KB Output is correct
25 Correct 56 ms 10116 KB Output is correct
26 Correct 37 ms 6164 KB Output is correct
27 Correct 36 ms 7044 KB Output is correct
28 Correct 63 ms 10172 KB Output is correct
29 Correct 69 ms 10060 KB Output is correct
30 Correct 28 ms 4052 KB Output is correct
31 Correct 67 ms 10180 KB Output is correct