답안 #681426

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681426 2023-01-13T05:11:37 Z sudheerays123 Intercastellar (JOI22_ho_t1) C++17
100 / 100
95 ms 9164 KB
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
const ll N = 100+5 , INF = 1e18 , MOD = 1e9+7;

void solve(){

	ll n;
	cin >> n;

	vector<ll> a(n+5),cnt(n+5);

	for(ll i = 1; i <= n; i++){
		cin >> a[i];
		ll x = a[i] , cur = 1;
		while((x%2)==0){
			x /= 2;
			cur*=2;
		}
		a[i] = x;
		cnt[i] = cnt[i-1]+cur;
	}

	ll q;
	cin >> q;

	while(q--){
		ll x;
		cin >> x;

		ll low = 1 , high = n;
		ll ind = n;

		while(low <= high){
			ll mid = (low+high)/2;

			if(cnt[mid] >= x){
				ind = mid;
				high = mid-1;
			}
			else low = mid+1;
		}

		cout << a[ind] << "\n";
	}

	
}

int main(){

	fast;

	ll tc = 1;
	// cin >> tc;
	while(tc--) solve();

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 19 ms 3948 KB Output is correct
4 Correct 26 ms 2336 KB Output is correct
5 Correct 65 ms 5548 KB Output is correct
6 Correct 29 ms 4044 KB Output is correct
7 Correct 47 ms 5520 KB Output is correct
8 Correct 45 ms 5596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 316 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 19 ms 3948 KB Output is correct
4 Correct 26 ms 2336 KB Output is correct
5 Correct 65 ms 5548 KB Output is correct
6 Correct 29 ms 4044 KB Output is correct
7 Correct 47 ms 5520 KB Output is correct
8 Correct 45 ms 5596 KB Output is correct
9 Correct 0 ms 316 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 25 ms 3020 KB Output is correct
24 Correct 31 ms 5196 KB Output is correct
25 Correct 65 ms 8696 KB Output is correct
26 Correct 49 ms 5580 KB Output is correct
27 Correct 41 ms 5500 KB Output is correct
28 Correct 76 ms 9164 KB Output is correct
29 Correct 75 ms 8704 KB Output is correct
30 Correct 39 ms 3736 KB Output is correct
31 Correct 95 ms 9072 KB Output is correct