제출 #941371

#제출 시각아이디문제언어결과실행 시간메모리
941371ReverberateIntercastellar (JOI22_ho_t1)C++14
100 / 100
79 ms11004 KiB
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define INF 1e18
#define DEBUG 0


signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<pair<int,int>>vect(n);
	for(int i=0;i<n;i++){
		int a,sz=1;
		cin>>a;
		while(a%2==0){
			a/=2;
			sz*=2;
		}
		vect[i]={a,sz};
	}
	vector<int>tmp;
	tmp.push_back(0);
	for(int i=0;i<n;i++){
		tmp.push_back(vect[i].second+tmp.back());
	}
	int q;
	cin>>q;
	while(q--){
		int t;
		cin>>t;
		auto it = (lower_bound(tmp.begin(),tmp.end(),t) - tmp.begin());
		cout<<vect[--it].first<<'\n';
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...