Submission #954420

# Submission time Handle Problem Language Result Execution time Memory
954420 2024-03-27T20:47:05 Z amirhoseinfar1385 Intercastellar (JOI22_ho_t1) C++17
100 / 100
63 ms 10836 KB
#include<bits/stdc++.h>
using namespace std;
const long long maxn=200000+10;
long long n;
long long all[maxn];
vector<long long>alls,allv;

void vorod(){
	cin>>n;
	for(long long i=1;i<=n;i++){
		cin>>all[i];
	}
}

void pre(){
	alls.resize(n+2);
	allv.resize(n+2);
	for(long long i=1;i<=n;i++){
		allv[i]=all[i];
		while((allv[i]&1)==0){
			allv[i]>>=1;
		}
		alls[i+1]=alls[i]+all[i]/allv[i];
	}
}

void solve(){
	long long q;
	cin>>q;
	for(long long i=0;i<q;i++){
		long long x;
		cin>>x;
		long long p=lower_bound(alls.begin(),alls.end(),x)-alls.begin();
		p--;
		cout<<allv[p]<<"\n";
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("inp.txt","r",stdin);
	vorod();
	pre();
	solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 464 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 17 ms 5520 KB Output is correct
4 Correct 26 ms 2676 KB Output is correct
5 Correct 42 ms 7248 KB Output is correct
6 Correct 24 ms 5468 KB Output is correct
7 Correct 41 ms 7252 KB Output is correct
8 Correct 41 ms 7256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 360 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 476 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 464 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 17 ms 5520 KB Output is correct
4 Correct 26 ms 2676 KB Output is correct
5 Correct 42 ms 7248 KB Output is correct
6 Correct 24 ms 5468 KB Output is correct
7 Correct 41 ms 7252 KB Output is correct
8 Correct 41 ms 7256 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 360 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 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 476 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 24 ms 3360 KB Output is correct
24 Correct 27 ms 6492 KB Output is correct
25 Correct 52 ms 10400 KB Output is correct
26 Correct 38 ms 6732 KB Output is correct
27 Correct 32 ms 6640 KB Output is correct
28 Correct 59 ms 10836 KB Output is correct
29 Correct 56 ms 10324 KB Output is correct
30 Correct 30 ms 3932 KB Output is correct
31 Correct 63 ms 10832 KB Output is correct