답안 #815905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815905 2023-08-09T02:17:52 Z vjudge1 Intercastellar (JOI22_ho_t1) C++17
100 / 100
283 ms 10852 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

void open(){
	if(fopen("input.inp", "r")){
		freopen("input.inp", "r", stdin);
		//freopen("output.out", "w", stdout);
	}
}

const int maxn = 2e5 + 5;

int n;
int A[maxn];
int q;
int lowest[maxn];
int depth[maxn];

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	open();

	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> A[i];
		int temp = A[i];
		int cnt = 0;
		while(temp % 2 == 0){
			temp /= 2;
			cnt++;
		}

		lowest[i] = temp;
		depth[i] = (1LL << cnt);
	}

	int cur_pos = 0;
	int prefix = 0;
	
	cin >> q;
	while(q--){
		int x;
		cin >> x;
		while(cur_pos < n && prefix < x){
			prefix += depth[++cur_pos];
		}

		cout << lowest[cur_pos] << endl;
	}

	return 0;
}

Compilation message

Main.cpp: In function 'void open()':
Main.cpp:8:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   freopen("input.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 50 ms 5444 KB Output is correct
4 Correct 163 ms 2640 KB Output is correct
5 Correct 221 ms 7080 KB Output is correct
6 Correct 120 ms 5296 KB Output is correct
7 Correct 223 ms 7112 KB Output is correct
8 Correct 222 ms 7184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 2 ms 388 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 50 ms 5444 KB Output is correct
4 Correct 163 ms 2640 KB Output is correct
5 Correct 221 ms 7080 KB Output is correct
6 Correct 120 ms 5296 KB Output is correct
7 Correct 223 ms 7112 KB Output is correct
8 Correct 222 ms 7184 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 2 ms 388 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 152 ms 3192 KB Output is correct
24 Correct 103 ms 6436 KB Output is correct
25 Correct 236 ms 10272 KB Output is correct
26 Correct 132 ms 6568 KB Output is correct
27 Correct 109 ms 6620 KB Output is correct
28 Correct 270 ms 10852 KB Output is correct
29 Correct 244 ms 10188 KB Output is correct
30 Correct 183 ms 3916 KB Output is correct
31 Correct 283 ms 10768 KB Output is correct