Submission #1017954

# Submission time Handle Problem Language Result Execution time Memory
1017954 2024-07-09T11:51:21 Z ag_1204 Intercastellar (JOI22_ho_t1) C++14
100 / 100
244 ms 10836 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pii pair<int,int>
#define vi vector<int>
#define si set<int>
#define pb push_back
 
void solve() {
    int n; cin>>n;
    int a[n];
    vi vals(n),sums(n);
    int sum=0;
    for (int i=0;i<n;i++) {
        cin>>a[i];
        int m=(a[i] & (-a[i]));
        a[i]=a[i]/(a[i] & (-a[i]));
        sum+=m;
        vals[i]=a[i]; sums[i]=sum;
    }
    int q; cin>>q;
    while(q--) {
        int x; cin>>x;
        int lo = 0,hi = n - 1;
        while (lo < hi) {
            int mid = (lo + hi) / 2;
            if (sums[mid] < x) lo = mid + 1;
            else hi = mid;
        }
        cout<<vals[hi]<<endl;
    }
    return;
}
 
int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int tt=1; //cin>>tt;
	while(tt--) {
	    solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 48 ms 5008 KB Output is correct
4 Correct 163 ms 2640 KB Output is correct
5 Correct 221 ms 7248 KB Output is correct
6 Correct 109 ms 5460 KB Output is correct
7 Correct 221 ms 7140 KB Output is correct
8 Correct 223 ms 7252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 1 ms 348 KB Output is correct
7 Correct 0 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 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 48 ms 5008 KB Output is correct
4 Correct 163 ms 2640 KB Output is correct
5 Correct 221 ms 7248 KB Output is correct
6 Correct 109 ms 5460 KB Output is correct
7 Correct 221 ms 7140 KB Output is correct
8 Correct 223 ms 7252 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 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 1 ms 348 KB Output is correct
15 Correct 0 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 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 137 ms 3416 KB Output is correct
24 Correct 102 ms 6240 KB Output is correct
25 Correct 244 ms 10428 KB Output is correct
26 Correct 128 ms 6480 KB Output is correct
27 Correct 134 ms 6740 KB Output is correct
28 Correct 241 ms 10804 KB Output is correct
29 Correct 234 ms 10216 KB Output is correct
30 Correct 172 ms 3924 KB Output is correct
31 Correct 239 ms 10836 KB Output is correct