제출 #1240384

#제출 시각아이디문제언어결과실행 시간메모리
1240384GeforgsIntercastellar (JOI22_ho_t1)C++20
100 / 100
54 ms5364 KiB
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <queue> #include <map> #include <unordered_map> #include <stack> #include <bitset> #include <string> #include <cstring> #include <iterator> #include <random> #define ll long long #define ld long double #define inf (ll)(2*1e18) #define sort(a) sort(a.begin(), a.end()) #define reverse(a) reverse(a.begin(), a.end()) #define pb push_back #define endl "\n" using namespace std; void solve(){ ll n, q, i, cnt, x, l, r, m; cin>>n; vector<pair<ll, ll>> a(n); for(i=0;i<n;++i){ cin>>x; cnt = 1; while(x%2 == 0){ x /= 2; cnt *= 2; } a[i] = {cnt, x}; } for(i=1;i<n;++i){ a[i].first += a[i-1].first; } cin>>q; for(i=0;i<q;++i){ cin>>cnt; l = -1; r = n-1; while(r - l > 1){ m = (l+r)/2; if(a[m].first < cnt){ l = m; }else{ r = m; } } cout<<a[r].second<<endl; } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); srand(time(nullptr)); ll t=1; // cin>>t; for(;t>0;--t){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...