# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1033615 | 2024-07-25T04:06:17 Z | nguyendinhanh1508 | Intercastellar (JOI22_ho_t1) | C++14 | 68 ms | 10724 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define mx 1000007 #define inf LLONG_MAX/20 #define pi pair<int, int> #define mp make_pair int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int a[n]; for(int i = 0; i < n; i++){ cin >> a[i]; } int pos[n]; int val[n]; int cur = 0; for(int i = 0; i < n; i++){ int curbit = 0; while((a[i] & (1 << curbit)) == 0){ curbit++; } val[i] = a[i] / (1 << curbit); pos[i] = cur; cur += (1 << curbit); } // for(int i = 0; i < n; i++){ // cerr << pos[i] << ' ' << val[i] << '\n'; // } int arrsize = cur; // cerr << arrsize << '\n'; int q; cin >> q; while(q--){ int x; cin >> x; x--; // cerr << x << '\n'; int l = 0, r = n - 1; int ans = 0; while(l <= r){ int mid = (l + r) / 2; if(pos[mid] <= x){ l = mid + 1; ans = val[mid]; } else r = mid - 1; } cout << ans << '\n'; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 15 ms | 5652 KB | Output is correct |
4 | Correct | 20 ms | 2648 KB | Output is correct |
5 | Correct | 35 ms | 7124 KB | Output is correct |
6 | Correct | 21 ms | 5468 KB | Output is correct |
7 | Correct | 35 ms | 7260 KB | Output is correct |
8 | Correct | 45 ms | 7304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 452 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 | 1 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 | 1 ms | 348 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 | 468 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 468 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 | 15 ms | 5652 KB | Output is correct |
4 | Correct | 20 ms | 2648 KB | Output is correct |
5 | Correct | 35 ms | 7124 KB | Output is correct |
6 | Correct | 21 ms | 5468 KB | Output is correct |
7 | Correct | 35 ms | 7260 KB | Output is correct |
8 | Correct | 45 ms | 7304 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 452 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 | 1 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 | 1 ms | 348 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 | 468 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 468 KB | Output is correct |
23 | Correct | 24 ms | 3232 KB | Output is correct |
24 | Correct | 30 ms | 6448 KB | Output is correct |
25 | Correct | 61 ms | 10292 KB | Output is correct |
26 | Correct | 35 ms | 6572 KB | Output is correct |
27 | Correct | 32 ms | 6800 KB | Output is correct |
28 | Correct | 68 ms | 10696 KB | Output is correct |
29 | Correct | 66 ms | 10372 KB | Output is correct |
30 | Correct | 26 ms | 3932 KB | Output is correct |
31 | Correct | 62 ms | 10724 KB | Output is correct |