Submission #937540

# Submission time Handle Problem Language Result Execution time Memory
937540 2024-03-04T08:14:50 Z Gromp15 Intercastellar (JOI22_ho_t1) C++17
100 / 100
60 ms 8364 KB
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define db double
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rint(l, r) uniform_int_distribution<int>(l, r)(rng)
template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
void test_case() {
	int n; cin >> n;
	vector<int> a(n);
	for (int &x : a) cin >> x;
	vector<ll> pref(n);
	for (int i = 0; i < n; i++) {
		pref[i] = (1 << __builtin_ctz(a[i])) + (i ? pref[i-1] : 0);
	}
	int q; cin >> q;
	while (q--) {
		ll pos; cin >> pos;
		int who = lower_bound(all(pref), pos) - pref.begin();
		cout << (a[who] >> __builtin_ctz(a[who])) << '\n';
	}



}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
//    cin >> t;
    while (t--) test_case();
}

# 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 15 ms 3416 KB Output is correct
4 Correct 26 ms 2092 KB Output is correct
5 Correct 40 ms 4820 KB Output is correct
6 Correct 23 ms 3416 KB Output is correct
7 Correct 42 ms 4692 KB Output is correct
8 Correct 41 ms 4940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 460 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 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 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 15 ms 3416 KB Output is correct
4 Correct 26 ms 2092 KB Output is correct
5 Correct 40 ms 4820 KB Output is correct
6 Correct 23 ms 3416 KB Output is correct
7 Correct 42 ms 4692 KB Output is correct
8 Correct 41 ms 4940 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 600 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 600 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 460 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 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 27 ms 2904 KB Output is correct
24 Correct 26 ms 4688 KB Output is correct
25 Correct 51 ms 8020 KB Output is correct
26 Correct 33 ms 5176 KB Output is correct
27 Correct 29 ms 4948 KB Output is correct
28 Correct 57 ms 8364 KB Output is correct
29 Correct 54 ms 7972 KB Output is correct
30 Correct 31 ms 3768 KB Output is correct
31 Correct 60 ms 8272 KB Output is correct