Submission #938094

# Submission time Handle Problem Language Result Execution time Memory
938094 2024-03-04T19:38:14 Z esomer Intercastellar (JOI22_ho_t1) C++17
100 / 100
65 ms 7760 KB
#include <bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int N; cin >> N;
	vector<int> A(N);
	for(auto &i : A) cin >> i;
	vector<long long> prefix(N, 0);
	for(int i = 0; i < N; i++){
		long long cnt = 1;
		while(A[i] % 2 == 0){
			cnt *= 2;
			A[i] /= 2;
		}
		if(i == 0) prefix[i] = cnt;
		else prefix[i] = prefix[i-1] + cnt;
	}
	int Q; cin >> Q;
	while(Q--){
		long long ind; cin >> ind;
		int lo = 0;
		int hi = N - 1;
		int bst = 0;
		while(lo <= hi){
			int mid = (lo + hi) / 2;
			if(prefix[mid] >= ind){
				bst = mid;
				hi = mid - 1;
			}else lo = mid + 1;
		}
		cout << A[bst] << "\n";
	}
}
# 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 3376 KB Output is correct
4 Correct 25 ms 2136 KB Output is correct
5 Correct 42 ms 4724 KB Output is correct
6 Correct 24 ms 3536 KB Output is correct
7 Correct 41 ms 4692 KB Output is correct
8 Correct 40 ms 4788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 452 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 1 ms 348 KB Output is correct
10 Correct 0 ms 452 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 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 3376 KB Output is correct
4 Correct 25 ms 2136 KB Output is correct
5 Correct 42 ms 4724 KB Output is correct
6 Correct 24 ms 3536 KB Output is correct
7 Correct 41 ms 4692 KB Output is correct
8 Correct 40 ms 4788 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 452 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 1 ms 348 KB Output is correct
18 Correct 0 ms 452 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 22 ms 3000 KB Output is correct
24 Correct 29 ms 4688 KB Output is correct
25 Correct 54 ms 7568 KB Output is correct
26 Correct 35 ms 4700 KB Output is correct
27 Correct 32 ms 4688 KB Output is correct
28 Correct 65 ms 7760 KB Output is correct
29 Correct 59 ms 7080 KB Output is correct
30 Correct 31 ms 3664 KB Output is correct
31 Correct 60 ms 7424 KB Output is correct