This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <fstream>
#include <iterator>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cctype>
#include <string>
#include <cassert>
#include <set>
#include <bitset>
#include <unordered_set>
using ll = int64_t;
#define pb push_back
#define all(a) a.begin(),a.end()
#define ppi pair<pair<int,int>,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int int64_t
// xcode cant include bits/stdc++.h
using namespace std;
//ifstream fin ("sleepy.in");
//ofstream fout ("sleepy.out");
/* /\_/\
* (= ._.)
* / > \>
*/
// encouraging cat
const int INF = 10000000000000000;
const int mod = 1000000007;
int32_t main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0;i < n;i++)
{
cin >> a[i];
}
vector<int> pref(n,0);
vector<int> val(n,0);
int s = 0;
int v = 1;
for (int i = 0;i < n;i++)
{
val[i] = a[i] / (a[i] & (-a[i]));
s += a[i] & (-a[i]);
pref[i] = s;
}
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 (pref[mid] < x)
lo = mid + 1;
else
hi = mid;
}
cout << val[hi] << '\n';
}
return 0;
}
Compilation message (stderr)
Main.cpp:32:9: warning: "/*" within comment [-Wcomment]
32 | /* /\_/\
|
Main.cpp: In function 'int32_t main()':
Main.cpp:50:9: warning: unused variable 'v' [-Wunused-variable]
50 | int v = 1;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |