Submission #531990

# Submission time Handle Problem Language Result Execution time Memory
531990 2022-03-02T02:57:50 Z Haruto810198 Intercastellar (JOI22_ho_t1) C++17
100 / 100
83 ms 10672 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

#define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d))
#define szof(x) ((int)(x).size())

#define vi vector<int>
#define pii pair<int, int>

#define F first
#define S second

#define pb push_back
#define eb emplace_back
#define mkp make_pair

const int INF = INT_MAX;
const int LNF = INF*INF;
const int MOD = 1000000007;
const int mod = 998244353;
const double eps = 1e-12;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

const int MAX = 200010;

int n, q;
int val[MAX], cnt[MAX];
int pref[MAX];

int solve(int T){
	int L = 1, R = n, mid;
	while(L < R){
		mid = (L + R) / 2;
		if(pref[mid] >= T) R = mid;
		else L = mid + 1;
	}
	return val[L];
}

signed main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	FOR(i, 1, n, 1){
		cin>>val[i];
		cnt[i] = 1;

		while(val[i] % 2 == 0){
			val[i] /= 2;
			cnt[i] *= 2;
		}

		pref[i] = pref[i-1] + cnt[i];
	}
	
	cin>>q;
	FOR(i, 1, q, 1){
		int T;
		cin>>T;
		cout<<solve(T)<<'\n';
	}
	
	return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 21 ms 5452 KB Output is correct
4 Correct 30 ms 2660 KB Output is correct
5 Correct 56 ms 7308 KB Output is correct
6 Correct 31 ms 5320 KB Output is correct
7 Correct 62 ms 7088 KB Output is correct
8 Correct 68 ms 7100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 380 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 21 ms 5452 KB Output is correct
4 Correct 30 ms 2660 KB Output is correct
5 Correct 56 ms 7308 KB Output is correct
6 Correct 31 ms 5320 KB Output is correct
7 Correct 62 ms 7088 KB Output is correct
8 Correct 68 ms 7100 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 380 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 28 ms 3272 KB Output is correct
24 Correct 37 ms 6320 KB Output is correct
25 Correct 78 ms 10356 KB Output is correct
26 Correct 49 ms 6468 KB Output is correct
27 Correct 41 ms 6628 KB Output is correct
28 Correct 83 ms 10672 KB Output is correct
29 Correct 82 ms 10160 KB Output is correct
30 Correct 41 ms 3908 KB Output is correct
31 Correct 83 ms 10660 KB Output is correct