제출 #1307591

#제출 시각아이디문제언어결과실행 시간메모리
1307591discontinuousIntercastellar (JOI22_ho_t1)C++20
100 / 100
116 ms21096 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define int long long const int MOD = 1e9 + 7; const int INF = 1e15; const int N = 1e6; int n, m, k, a, b, c, d, h, l, r, q, u, v, x, y; void solve() { cin >> n; vector<int> arr(n); vector<int> brr(n); vector<int> crr(n); for(int i = 0; i<n; i++) { cin >> arr[i]; x = 0; for(int j = 0; j<31; j++) { if(arr[i]&(1<<j)) break; x++; } // cout << x << " "; //we must divide by 2, x times brr[i] = (1<<x); crr[i] = arr[i]/brr[i]; } // cout << "\n"; map<int, int> mpp; vector<int> pref(n); pref[0] = brr[0]; mpp[pref[0]] = 0; for(int i = 1; i<n; i++) { pref[i] = pref[i-1] + brr[i]; mpp[pref[i]] = i; } // for(auto j : brr) cout << j << " "; // cout << "\n"; cin >> q; while(q--) { cin >> a; // cout << a << " "; auto it = lower_bound(pref.begin(), pref.end(), a); // cout << *it << " "; cout << crr[mpp[*it]] << "\n"; } } int32_t main() { ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); int tc = 1; // cin >> tc; while(tc--) { solve(); cout << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...