# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
576228 | Aldas25 | Intercastellar (JOI22_ho_t1) | C++14 | 103 ms | 12376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
//#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
*/
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 500100, MAXK = 20;
const ll INF = 1e14;
//const ll MOD = 1e9+7;
const ll MOD = 998244353;
void setIO()
{
FAST_IO;
}
void setIO(string s)
{
FAST_IO;
freopen((s+".in").c_str(), "r", stdin);
freopen((s+".out").c_str(), "w", stdout);
}
int n, q;
ll a[MAXN];
ll val[MAXN], cnt[MAXN], pref[MAXN];
int main()
{
setIO();
cin >> n;
FOR(i, 1, n) cin >> a[i];
FOR(i, 1, n) {
val[i] = a[i];
while (val[i]%2 == 0) {
val[i] /= 2;
}
cnt[i] = a[i] / val[i];
pref[i] = pref[i-1] + cnt[i];
}
cin >> q;
while (q--) {
ll x; cin >> x;
int le = 1, ri = n;
while (le < ri) {
int m = (le+ri)/2;
if (pref[m] >= x) ri = m;
else le = m+1;
}
cout << val[le] << "\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |