답안 #1115879

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1115879 2024-11-21T03:10:41 Z TrieTr Intercastellar (JOI22_ho_t1) C++14
100 / 100
64 ms 13384 KB
#include<bits/stdc++.h>
using namespace std;

void local() {
    #define taskname ""
    if (fopen(taskname".inp", "r")) {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
}

#define ll long long
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template<class X, class Y> bool mini(X &a, const Y &b) {return (a > b) ? a = b, true : false;}
template<class X, class Y> bool maxi(X &a, const Y &b) {return (a < b) ? a = b, true : false;}

const int N = 1e6 + 5;

int n, a[N];
ll pf[N]; int lg[N];

int main() {
    fastio; local();
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) {
    	int x = a[i];
    	while(x % 2 == 0) lg[i]++, x /= 2;
    	pf[i] = pf[i - 1] + (1ll << lg[i]);
    }
    int q; cin >> q;
    while(q--) {
    	ll p; cin >> p;
    	int lo = 1, hi = n, pos = 0;
    	while(lo <= hi) {
    		int mid = (lo + hi) >> 1;
    		if(pf[mid] < p) lo = (pos = mid) + 1;
    		else hi = mid - 1;
    	}
    	pos++;
    	cout << a[pos] / (1ll << lg[pos]) << '\n';
    }
}

Compilation message

Main.cpp: In function 'void local()':
Main.cpp:7:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 15 ms 6224 KB Output is correct
4 Correct 20 ms 6368 KB Output is correct
5 Correct 42 ms 9660 KB Output is correct
6 Correct 21 ms 6736 KB Output is correct
7 Correct 39 ms 9800 KB Output is correct
8 Correct 34 ms 9808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2516 KB Output is correct
3 Correct 1 ms 2552 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 15 ms 6224 KB Output is correct
4 Correct 20 ms 6368 KB Output is correct
5 Correct 42 ms 9660 KB Output is correct
6 Correct 21 ms 6736 KB Output is correct
7 Correct 39 ms 9800 KB Output is correct
8 Correct 34 ms 9808 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2516 KB Output is correct
11 Correct 1 ms 2552 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 2 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 21 ms 5012 KB Output is correct
24 Correct 27 ms 8008 KB Output is correct
25 Correct 55 ms 13012 KB Output is correct
26 Correct 35 ms 8520 KB Output is correct
27 Correct 33 ms 8520 KB Output is correct
28 Correct 59 ms 13384 KB Output is correct
29 Correct 56 ms 12872 KB Output is correct
30 Correct 28 ms 5632 KB Output is correct
31 Correct 64 ms 13384 KB Output is correct