이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>  
#define int long long 
#define pb push_back
 
#define F first
 
#define S second
 
using namespace std;
 
const int N = 2e5 + 10;
 
const int mod = 1e9 + 7;
 
const int inf = 1e9;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
 	int n;
 	cin >> n;
 	vector<int>a(n + 1);
 	vector<pair<int,int>>pref(n + 1);
 	for(int i = 1; i <= n; i++) {
 		cin >> a[i];
 		int pw = 1;
 		while(a[i] % (pw * 2) == 0) pw *= 2;
 		pref[i] = {a[i] / pw,pw};
 		pref[i].S += pref[i - 1].S;
 	}
 	int q;
 	cin >> q;
 	while(q--) {
 		int x;
 		cin >> x;
 		int l = 1,r = n,ans = -1;
 		while(l <= r) {
 			int mid = (l + r) / 2;
 			if(pref[mid].S <= x) {
 				ans = mid;
 				l = mid + 1;
 			}else {
 				r = mid - 1;
 			}
 		}
 		assert(ans != -1);
 		if(pref[ans].S < x) ans++;
 		cout << pref[ans].F << "\n";
 	}
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |