/**
* author: hashman
* created:
**/
#include <bits/stdc++.h>
using namespace std;
string to_string(string s) {
return '"' + s + '"';
}
string to_string(const char* s) {
return to_string((string) s);
}
string to_string(bool b) {
return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
bool first = true;
string res = "{";
for (const auto &x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
void debug_out() {
cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__);
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<pair<int, int>> ans;
for (int i = 0; i < n; i++) {
int old = a[i];
while (a[i] % 2 == 0) {
a[i] = a[i] / 2;
}
ans.push_back(make_pair(a[i], old / a[i]));
}
int ptr = 0;
int64_t consumed = 0;
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int64_t x;
cin >> x;
while (consumed + ans[ptr].second < x) {
consumed += ans[ptr].second;
ptr++;
}
cout << ans[ptr].first << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
3892 KB |
Output is correct |
4 |
Correct |
20 ms |
2264 KB |
Output is correct |
5 |
Correct |
37 ms |
5048 KB |
Output is correct |
6 |
Correct |
21 ms |
3800 KB |
Output is correct |
7 |
Correct |
42 ms |
5048 KB |
Output is correct |
8 |
Correct |
35 ms |
5068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
456 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 |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
3892 KB |
Output is correct |
4 |
Correct |
20 ms |
2264 KB |
Output is correct |
5 |
Correct |
37 ms |
5048 KB |
Output is correct |
6 |
Correct |
21 ms |
3800 KB |
Output is correct |
7 |
Correct |
42 ms |
5048 KB |
Output is correct |
8 |
Correct |
35 ms |
5068 KB |
Output is correct |
9 |
Correct |
0 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 |
456 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 |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
20 ms |
3020 KB |
Output is correct |
24 |
Correct |
26 ms |
4812 KB |
Output is correct |
25 |
Correct |
46 ms |
8136 KB |
Output is correct |
26 |
Correct |
34 ms |
5324 KB |
Output is correct |
27 |
Correct |
37 ms |
5272 KB |
Output is correct |
28 |
Correct |
56 ms |
8656 KB |
Output is correct |
29 |
Correct |
54 ms |
8176 KB |
Output is correct |
30 |
Correct |
30 ms |
3788 KB |
Output is correct |
31 |
Correct |
58 ms |
8528 KB |
Output is correct |