Submission #702630

# Submission time Handle Problem Language Result Execution time Memory
702630 2023-02-24T15:54:23 Z Chal1shkan Intercastellar (JOI22_ho_t1) C++14
100 / 100
86 ms 9148 KB
# include <bits/stdc++.h>
 
# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define sz(x) ((int)(x).size())
# define deb(x) cerr << #x  << " = " << x << endl; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const ll maxn = 2e5 + 25;
const ll inf = 2e9 + 0;
const ll mod = 998244353;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};
 
using namespace std;

ll n, q, a[maxn];
ll pref[maxn];

void ma1n (/* SABR */)
{
	cin >> n;
	for (ll i = 1; i <= n; ++i)
	{
		cin >> a[i];
		ll c = 1;
		while (a[i] % 2 == 0)
		{
			c *= 2;
			a[i] /= 2;
		}
		pref[i] = pref[i - 1] + c;
	}
	cin >> q;
	while (q--)
	{
		ll w;
		cin >> w;
		ll l = 1, r = n, id = n;
		while (l <= r)
		{
			ll mid = (l + r) >> 1;
			if (pref[mid] < w)
			{
				l = mid + 1;
			}
			else
			{
				r = mid - 1;
				id = mid;
			}
		}
		cout << a[id] << nl;
	}
}
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
//    freopen("angry.in", "r", stdin);
//    freopen("angry.out", "w", stdout);
    int ttt = 1;
//  cin >> ttt;
    for (int test = 1; test <= ttt; ++test)
    {
//      cout << "Case " << test << ":" << ' ';
        ma1n();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 18 ms 3612 KB Output is correct
4 Correct 28 ms 2276 KB Output is correct
5 Correct 52 ms 5492 KB Output is correct
6 Correct 36 ms 4004 KB Output is correct
7 Correct 48 ms 5552 KB Output is correct
8 Correct 46 ms 5576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 18 ms 3612 KB Output is correct
4 Correct 28 ms 2276 KB Output is correct
5 Correct 52 ms 5492 KB Output is correct
6 Correct 36 ms 4004 KB Output is correct
7 Correct 48 ms 5552 KB Output is correct
8 Correct 46 ms 5576 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 26 ms 3012 KB Output is correct
24 Correct 33 ms 5252 KB Output is correct
25 Correct 81 ms 8708 KB Output is correct
26 Correct 47 ms 5524 KB Output is correct
27 Correct 40 ms 5480 KB Output is correct
28 Correct 74 ms 9148 KB Output is correct
29 Correct 86 ms 8628 KB Output is correct
30 Correct 40 ms 3752 KB Output is correct
31 Correct 75 ms 9064 KB Output is correct