Submission #936619

# Submission time Handle Problem Language Result Execution time Memory
936619 2024-03-02T11:57:53 Z william950615 Intercastellar (JOI22_ho_t1) C++14
100 / 100
56 ms 9296 KB
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define mkp make_pair
#define PH push
#define PB push_back
#define REP(i,N) for( int i = 0; i < (N); ++i )
#define FOR(i,a,b) for( int i = (a); i <= (b); ++i )
#define ALL(x) begin(x), end(x)
#define MEM(x) memset(x, 0, sizeof(x))

typedef long long ll;
typedef pair<int,int> pii;
template<typename T>
using V=vector<T>;

void solve() {
	int N; cin >> N;
	V<pair<ll,ll>> vc(N);
	for( auto &i : vc )
		cin >> i.F, i.S = 1;
	for( auto &i : vc ) {
		while( i.F % 2 == 0 ) {
			i.S <<=1;
			i.F >>=1;
		}
	}
	int Q; cin >> Q;
	ll sum = 0;
	int lpos = 0;
	REP(i,Q) {
		ll x; cin >> x;
		while( sum+vc[lpos].S < x ) {
			sum += vc[lpos].S;
			lpos++;
		}
		cout << vc[lpos].F << '\n';
	}

}
int main() {
	int T = 1;
#ifdef LOCAL
	freopen( "input.txt", "r", stdin);
	freopen( "output.txt", "w", stdout );
	cin >> T;
#else
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
	while(T--) solve();

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 500 KB Output is correct
3 Correct 15 ms 3932 KB Output is correct
4 Correct 22 ms 2376 KB Output is correct
5 Correct 37 ms 5460 KB Output is correct
6 Correct 22 ms 4176 KB Output is correct
7 Correct 37 ms 5468 KB Output is correct
8 Correct 36 ms 5764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 464 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 476 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 500 KB Output is correct
3 Correct 15 ms 3932 KB Output is correct
4 Correct 22 ms 2376 KB Output is correct
5 Correct 37 ms 5460 KB Output is correct
6 Correct 22 ms 4176 KB Output is correct
7 Correct 37 ms 5468 KB Output is correct
8 Correct 36 ms 5764 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 464 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 476 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 21 ms 3048 KB Output is correct
24 Correct 33 ms 5212 KB Output is correct
25 Correct 52 ms 8856 KB Output is correct
26 Correct 32 ms 5660 KB Output is correct
27 Correct 30 ms 5472 KB Output is correct
28 Correct 56 ms 9296 KB Output is correct
29 Correct 52 ms 8784 KB Output is correct
30 Correct 36 ms 3796 KB Output is correct
31 Correct 55 ms 9296 KB Output is correct