Submission #1017954

#TimeUsernameProblemLanguageResultExecution timeMemory
1017954ag_1204Intercastellar (JOI22_ho_t1)C++14
100 / 100
244 ms10836 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int #define pii pair<int,int> #define vi vector<int> #define si set<int> #define pb push_back void solve() { int n; cin>>n; int a[n]; vi vals(n),sums(n); int sum=0; for (int i=0;i<n;i++) { cin>>a[i]; int m=(a[i] & (-a[i])); a[i]=a[i]/(a[i] & (-a[i])); sum+=m; vals[i]=a[i]; sums[i]=sum; } int q; cin>>q; while(q--) { int x; cin>>x; int lo = 0,hi = n - 1; while (lo < hi) { int mid = (lo + hi) / 2; if (sums[mid] < x) lo = mid + 1; else hi = mid; } cout<<vals[hi]<<endl; } return; } int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int tt=1; //cin>>tt; while(tt--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...