# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
545587 | 2022-04-04T23:20:41 Z | aryan12 | Intercastellar (JOI22_ho_t1) | C++17 | 87 ms | 10892 KB |
#include <bits/stdc++.h> using namespace std; #define int long long mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count()); void Solve() { int n; cin >> n; vector<int> a(n + 1); for(int i = 1; i <= n; i++) { cin >> a[i]; } vector<pair<int, int> > final; for(int i = 1; i <= n; i++) { int cnt = 1; while(a[i] % 2 == 0) { a[i] /= 2; cnt *= 2; } final.push_back(make_pair(a[i], cnt)); } for(int i = 1; i < final.size(); i++) { final[i].second += final[i - 1].second; } int q; cin >> q; while(q--) { int x; cin >> x; int l = 0, r = final.size() - 1; int ans = r; while(l <= r) { int mid = (l + r) / 2; if(final[mid].second >= x) { ans = mid; r = mid - 1; } else { l = mid + 1; } } cout << final[ans].first << "\n"; } } int32_t main() { auto begin = std::chrono::high_resolution_clock::now(); ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t--) { Solve(); } auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin); cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 24 ms | 6688 KB | Output is correct |
4 | Correct | 29 ms | 2872 KB | Output is correct |
5 | Correct | 52 ms | 7196 KB | Output is correct |
6 | Correct | 29 ms | 6340 KB | Output is correct |
7 | Correct | 50 ms | 7228 KB | Output is correct |
8 | Correct | 54 ms | 7352 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 352 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 352 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 24 ms | 6688 KB | Output is correct |
4 | Correct | 29 ms | 2872 KB | Output is correct |
5 | Correct | 52 ms | 7196 KB | Output is correct |
6 | Correct | 29 ms | 6340 KB | Output is correct |
7 | Correct | 50 ms | 7228 KB | Output is correct |
8 | Correct | 54 ms | 7352 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 352 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 352 KB | Output is correct |
23 | Correct | 28 ms | 3448 KB | Output is correct |
24 | Correct | 36 ms | 7172 KB | Output is correct |
25 | Correct | 78 ms | 10408 KB | Output is correct |
26 | Correct | 47 ms | 6724 KB | Output is correct |
27 | Correct | 42 ms | 7316 KB | Output is correct |
28 | Correct | 78 ms | 10892 KB | Output is correct |
29 | Correct | 78 ms | 10316 KB | Output is correct |
30 | Correct | 40 ms | 4036 KB | Output is correct |
31 | Correct | 87 ms | 10820 KB | Output is correct |