제출 #1295393

#제출 시각아이디문제언어결과실행 시간메모리
1295393hynmjIntercastellar (JOI22_ho_t1)C++20
100 / 100
52 ms5368 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const long long N = 2e5 + 5; int a[N]; int psum[N]; int no_of_pieces(int n) { for (int i = 0; i < 64; i++) { int mask = 1ll << i; if (n & mask) { return n & mask; } } return 0; } int minimized(int k) { if (k == 0) return 0; while ((k & 1) == 0) k >>= 1; return k; } void solve() { int n, q; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { psum[i] = psum[i - 1] + no_of_pieces(a[i - 1]); // cout << a[i - 1] << ' ' << no_of_pieces(a[i - 1]) << endl; } cin >> q; int e; for (int i = 0; i < q; i++) { cin >> e; int k = lower_bound(psum, psum + n + 1, e) - psum; k--; // cout << minimized(a[k]) << '\n'; cout << minimized(a[k]) << '\n'; } // for (int i = 0; i <= n; i++) // { // // // cout << a[i] << ' ' << psum[i + 1] << endl; // cout << psum[i] << ' '; // } } signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int t = 1; // cin >> t; for (int i = 1; i <= t; i++) { // cout << "Case #" << i << ':' << ' '; solve(); cout << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...