Submission #805891

# Submission time Handle Problem Language Result Execution time Memory
805891 2023-08-04T01:53:41 Z Faee Intercastellar (JOI22_ho_t1) C++14
100 / 100
61 ms 6736 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define endl "\n"
#define pii pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define pque priority_queue
#define pqueg priority_queue<ll,vector<ll>,greater<ll>>
#define que queue<ll>
#define FOR(m,i,n) for(int i=(m); i<=(n); i++)
#define FORM(m,i,n) for(int i=(m); i>=(n); i--)
#define all(v) sort(v.begin(),v.end())
ll n,q,x,freq;
ll l,r,m,ans;
ll pref[200200];
ll a[200200];
int main() {
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cin >> n;
  	FOR(1,i,n) {
    	cin >> a[i];
    	freq = 1;
    	while(a[i] % 2 == 0) {
      		a[i] /= 2;
      		freq *= 2;
    	}
   	 	pref[i] = pref[i-1] + freq;
  	}
  	cin >> q;
  	while(q--) {
	    cin >> x;
	    l = 1;
	    r = n;
	    while(l <= r) {
	      	m = (l+r)/2;
	      	if(pref[m] >= x) {
	        	ans = a[m];
	        	r = m - 1;
	     	}
      		else {
        		l = m + 1;
      		}
		}
		cout << ans << endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 15 ms 3996 KB Output is correct
4 Correct 24 ms 1992 KB Output is correct
5 Correct 39 ms 5204 KB Output is correct
6 Correct 23 ms 3796 KB Output is correct
7 Correct 40 ms 5152 KB Output is correct
8 Correct 40 ms 5164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 340 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 340 KB Output is correct
10 Correct 1 ms 340 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 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 15 ms 3996 KB Output is correct
4 Correct 24 ms 1992 KB Output is correct
5 Correct 39 ms 5204 KB Output is correct
6 Correct 23 ms 3796 KB Output is correct
7 Correct 40 ms 5152 KB Output is correct
8 Correct 40 ms 5164 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 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 340 KB Output is correct
18 Correct 1 ms 340 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 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 28 ms 2764 KB Output is correct
24 Correct 28 ms 4684 KB Output is correct
25 Correct 59 ms 6736 KB Output is correct
26 Correct 35 ms 4212 KB Output is correct
27 Correct 32 ms 4364 KB Output is correct
28 Correct 61 ms 5884 KB Output is correct
29 Correct 56 ms 5136 KB Output is correct
30 Correct 32 ms 2776 KB Output is correct
31 Correct 60 ms 5652 KB Output is correct