답안 #1000144

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000144 2024-06-16T17:43:56 Z THXuan Intercastellar (JOI22_ho_t1) C++14
100 / 100
71 ms 9300 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define INF 1e9
using namespace std;
typedef long long ll;

void solve()
{
	int n; cin >> n;
	vector<ll>a(n + 1),s(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) {
		if (a[i] % 2 == 1) {
			s[i] = s[i - 1] + 1;
		}
		else {
			for (int j = 1; j <= 30; j++) {
				ll num = (1 << j);
				if ((a[i] / num) % 2 == 1) {
					a[i] = a[i] / num;
					s[i] = s[i - 1] + num;
					break;
				}
			}
		}
	}
	int q; cin >> q;
	while (q--) {
		ll x; cin >> x;
		int lo = 1; int hi = n;
		while (lo < hi) {
			int mid = (lo + hi) / 2;
			if (s[mid] < x)lo = mid + 1;
			else hi = mid;
		}
		cout << a[lo] << "\n";
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;// cin>>t;
	while (t--) solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 15 ms 3480 KB Output is correct
4 Correct 20 ms 1480 KB Output is correct
5 Correct 35 ms 3800 KB Output is correct
6 Correct 20 ms 3164 KB Output is correct
7 Correct 36 ms 3920 KB Output is correct
8 Correct 38 ms 3924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 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 1 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 1 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 600 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 3480 KB Output is correct
4 Correct 20 ms 1480 KB Output is correct
5 Correct 35 ms 3800 KB Output is correct
6 Correct 20 ms 3164 KB Output is correct
7 Correct 36 ms 3920 KB Output is correct
8 Correct 38 ms 3924 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 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 1 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 1 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 600 KB Output is correct
23 Correct 18 ms 3096 KB Output is correct
24 Correct 24 ms 5220 KB Output is correct
25 Correct 47 ms 8788 KB Output is correct
26 Correct 34 ms 5536 KB Output is correct
27 Correct 32 ms 5712 KB Output is correct
28 Correct 60 ms 9296 KB Output is correct
29 Correct 60 ms 8788 KB Output is correct
30 Correct 27 ms 3676 KB Output is correct
31 Correct 71 ms 9300 KB Output is correct