Submission #536714

# Submission time Handle Problem Language Result Execution time Memory
536714 2022-03-14T00:08:30 Z kym Intercastellar (JOI22_ho_t1) C++14
100 / 100
94 ms 10772 KB
#include <bits/stdc++.h>
using namespace std;
#define int ll 
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
#define reach cerr << "LINE: " << __LINE__ << "\n";
#else
#define db(x)
#define db2(x,y)
#define db3(a,b,c)
#define dbv(v)
#define dbvp(v)
#define dba(a,ss,ee)
#define reach 
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define g0(x) get<0>(x)
#define g1(x) get<1>(x)
#define g2(x) get<2>(x)
#define g3(x) get<3>(x)
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
typedef tuple<ll,ll,ll,ll> ti4;
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, const T b) { a=max(a,b); }
template <typename T> void chmin(T& a, const T b) { a=min(a,b); }
const int MAXN = 200005;
int A[MAXN];
int R[MAXN];
int sum[MAXN];
int n;
int Q; 
int32_t main() 
{
	IAMSPEED
	cin >> n;
	FOR(i,1,n) cin >> A[i];
	FOR(i,1,n) R[i] = 1;
	cin >> Q;
	FOR(i,1,n) {
		while(A[i]%2==0) {
			A[i]/=2;
			R[i]*=2;
		}
	}
	FOR(i,1,n) sum[i] = sum[i-1] + R[i];
	while(Q--){
		int x; cin >> x;
		int lo = 0, hi = n+1;
		while(lo < hi - 1) {
			int mid = (lo+hi)/2;
			if(sum[mid] >= x)hi=mid;
			else lo=mid;
		}
		cout << A[hi] << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 22 ms 5476 KB Output is correct
4 Correct 31 ms 2684 KB Output is correct
5 Correct 60 ms 7116 KB Output is correct
6 Correct 34 ms 5376 KB Output is correct
7 Correct 54 ms 7024 KB Output is correct
8 Correct 51 ms 7116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 388 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 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 22 ms 5476 KB Output is correct
4 Correct 31 ms 2684 KB Output is correct
5 Correct 60 ms 7116 KB Output is correct
6 Correct 34 ms 5376 KB Output is correct
7 Correct 54 ms 7024 KB Output is correct
8 Correct 51 ms 7116 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 328 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 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2 ms 388 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 40 ms 3276 KB Output is correct
24 Correct 42 ms 6344 KB Output is correct
25 Correct 73 ms 10296 KB Output is correct
26 Correct 51 ms 6564 KB Output is correct
27 Correct 43 ms 6688 KB Output is correct
28 Correct 90 ms 10772 KB Output is correct
29 Correct 93 ms 10256 KB Output is correct
30 Correct 45 ms 3916 KB Output is correct
31 Correct 94 ms 10700 KB Output is correct