답안 #1088381

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088381 2024-09-14T10:14:03 Z peacebringer1667 Intercastellar (JOI22_ho_t1) C++17
100 / 100
53 ms 11684 KB
#include<bits/stdc++.h>
#define ll long long
#define ldb long double
#define fi first
#define se second
#define sza(a) (int)a.size()
#define pir pair<int,int>
#define pirll pair<ll,ll>
using namespace std;
const int maxn = 2e5 + 5;
const ll cap = 1e15;

struct CTDL{
	ll l = 0,r = 0;int val = 0;
};
vector <CTDL> vec;
int a[maxn],p = 0;

void gen(int n){
	ll cur = 0;
	
	for (int i = 1 ; i <= n ; i++){
		int cnt = 1;
		while (a[i] % 2 == 0){
			a[i] /= 2;cnt *= 2;
		}
		
		vec.push_back({cur + 1,cur + cnt,a[i]});
		cur += cnt;
		
		if (cur > cap) break;
	}
}

int solve(ll x){
	while (p < vec.size() && vec[p].r < x) p++;
	return vec[p].val;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	int n,q;
	cin >> n;
	for (int i = 1 ; i <= n ; i++) cin >> a[i];
	gen(n);
	
	cin >> q;
	while (q--){
		ll x;
		cin >> x;
		cout << solve(x) << "\n";
	}

	return 0;
}

Compilation message

Main.cpp: In function 'int solve(long long int)':
Main.cpp:36:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<CTDL>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  while (p < vec.size() && vec[p].r < x) p++;
      |         ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 18 ms 8008 KB Output is correct
4 Correct 19 ms 3020 KB Output is correct
5 Correct 33 ms 8140 KB Output is correct
6 Correct 25 ms 7884 KB Output is correct
7 Correct 41 ms 8140 KB Output is correct
8 Correct 33 ms 8164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 18 ms 8008 KB Output is correct
4 Correct 19 ms 3020 KB Output is correct
5 Correct 33 ms 8140 KB Output is correct
6 Correct 25 ms 7884 KB Output is correct
7 Correct 41 ms 8140 KB Output is correct
8 Correct 33 ms 8164 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 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 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 22 ms 3540 KB Output is correct
24 Correct 25 ms 8632 KB Output is correct
25 Correct 45 ms 11428 KB Output is correct
26 Correct 34 ms 7348 KB Output is correct
27 Correct 34 ms 8648 KB Output is correct
28 Correct 52 ms 11684 KB Output is correct
29 Correct 51 ms 11188 KB Output is correct
30 Correct 25 ms 4296 KB Output is correct
31 Correct 53 ms 11568 KB Output is correct