#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
int mod=1e9+7;
const int N=2e5+5;
template<class x>
using ordered_multiset = tree<x, null_type,less_equal<x>, rb_tree_tag,tree_order_statistics_node_update>;
int n;
vector<pair<int,int> > v;
void cl(int x) {
pair<int,int> gg={1e10,1e10};
for (int i=1;i*i<=x;i++) {
int j=x/i;
if (x%i==0 && x%j==0 && (i%2!=0 || j%2!=0)) {
pair<int,int> tmp;
if (i%2!=0 && j%2!=0) tmp={min(i,j),max(i,j)};
else {
if (i%2!=0) tmp={j,i};
else tmp={i,j};
}
gg=min(gg,tmp);
}
}
v.push_back(gg);
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen(".in", "r", stdin); freopen(".out", "w", stdout);
cin>>n;
for (int i=0;i<n;i++) {
int x; cin>>x;
cl(x);
}
pair<int,int> prfx[n+1];
for (int i=1;i<=n;i++) {
prfx[i].first=v[i-1].first+prfx[i-1].first;
prfx[i].second=v[i-1].second;
}
int q; cin>>q;
while (q--) {
int x; cin>>x;
pair<int,int> tmp={x,0};
int i=upper_bound(prfx+1,prfx+(n+1),tmp)-prfx+1;
i--;
cout<<prfx[i].second<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
25 ms |
7104 KB |
Output is correct |
4 |
Correct |
33 ms |
3164 KB |
Output is correct |
5 |
Correct |
57 ms |
8816 KB |
Output is correct |
6 |
Correct |
36 ms |
6848 KB |
Output is correct |
7 |
Correct |
59 ms |
8764 KB |
Output is correct |
8 |
Correct |
55 ms |
8804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
79 ms |
332 KB |
Output is correct |
7 |
Correct |
114 ms |
336 KB |
Output is correct |
8 |
Correct |
151 ms |
340 KB |
Output is correct |
9 |
Correct |
11 ms |
324 KB |
Output is correct |
10 |
Correct |
35 ms |
324 KB |
Output is correct |
11 |
Correct |
147 ms |
348 KB |
Output is correct |
12 |
Correct |
176 ms |
340 KB |
Output is correct |
13 |
Correct |
139 ms |
440 KB |
Output is correct |
14 |
Correct |
157 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
25 ms |
7104 KB |
Output is correct |
4 |
Correct |
33 ms |
3164 KB |
Output is correct |
5 |
Correct |
57 ms |
8816 KB |
Output is correct |
6 |
Correct |
36 ms |
6848 KB |
Output is correct |
7 |
Correct |
59 ms |
8764 KB |
Output is correct |
8 |
Correct |
55 ms |
8804 KB |
Output is correct |
9 |
Correct |
1 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 |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
320 KB |
Output is correct |
14 |
Correct |
79 ms |
332 KB |
Output is correct |
15 |
Correct |
114 ms |
336 KB |
Output is correct |
16 |
Correct |
151 ms |
340 KB |
Output is correct |
17 |
Correct |
11 ms |
324 KB |
Output is correct |
18 |
Correct |
35 ms |
324 KB |
Output is correct |
19 |
Correct |
147 ms |
348 KB |
Output is correct |
20 |
Correct |
176 ms |
340 KB |
Output is correct |
21 |
Correct |
139 ms |
440 KB |
Output is correct |
22 |
Correct |
157 ms |
348 KB |
Output is correct |
23 |
Execution timed out |
2072 ms |
1204 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |