Submission #784424

# Submission time Handle Problem Language Result Execution time Memory
784424 2023-07-16T06:15:51 Z gun_gan Intercastellar (JOI22_ho_t1) C++17
100 / 100
77 ms 8472 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MX = 2e5 + 5;

int N, Q;
int a[MX];

int main() {
      cin.tie(0); ios_base::sync_with_stdio(0); 

      cin >> N;
      for(int i = 0; i < N; i++) cin >> a[i];

      reverse(a, a + N);

      vector<pair<ll, ll>> b;
      for(int i = 0; i < N; i++) {
            int k = a[i];
            while(!(k % 2)) k /= 2;

            b.push_back({a[i] / k, k});
      }

      reverse(b.begin(), b.end());

      ll sum = 0;
      for(auto &[cnt, x] : b) {
            sum += cnt;
            cnt = sum;
      }

      cin >> Q;
      for(int i = 1; i <= Q; i++) {
            ll x;
            cin >> x;

            int l = 0, r = (int) b.size() - 1, res = 0;
            while(l <= r) {
                  int mid = (l + r) >> 1;

                  if(b[mid].first >= x) {
                        res = mid, r = mid - 1;
                  } else {
                        l = mid + 1;
                  }
            }

            cout << b[res].second << '\n';
      }
      
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 232 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 19 ms 5964 KB Output is correct
4 Correct 27 ms 2592 KB Output is correct
5 Correct 44 ms 6440 KB Output is correct
6 Correct 33 ms 5648 KB Output is correct
7 Correct 50 ms 6444 KB Output is correct
8 Correct 46 ms 6484 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 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 232 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 19 ms 5964 KB Output is correct
4 Correct 27 ms 2592 KB Output is correct
5 Correct 44 ms 6440 KB Output is correct
6 Correct 33 ms 5648 KB Output is correct
7 Correct 50 ms 6444 KB Output is correct
8 Correct 46 ms 6484 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 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 23 ms 3276 KB Output is correct
24 Correct 36 ms 6648 KB Output is correct
25 Correct 58 ms 8472 KB Output is correct
26 Correct 37 ms 5640 KB Output is correct
27 Correct 37 ms 6432 KB Output is correct
28 Correct 77 ms 7692 KB Output is correct
29 Correct 66 ms 6832 KB Output is correct
30 Correct 46 ms 3772 KB Output is correct
31 Correct 70 ms 7384 KB Output is correct