답안 #703250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703250 2023-02-26T18:12:13 Z MilosMilutinovic Intercastellar (JOI22_ho_t1) C++14
100 / 100
86 ms 10156 KB
/**
 *    author:  wxhtzdy
 *    created: 26.02.2023 19:09:42
**/
#include <bits/stdc++.h>

using namespace std;

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<long long, int>> f;
  f.emplace_back(0, 0);
  for (int i = 0; i < n; i++) {
    int x = a[i];
    while (x % 2 == 0) {
      x /= 2;
    }
    f.emplace_back(f.back().first + a[i] / x, x);
  }
  int q;
  cin >> q;
  while (q--) {
    long long x;
    cin >> x;
    int low = 0, high = f.size() - 1, pos = 0;
    while (low <= high) {
      int mid = low + high >> 1;
      if (f[mid].first >= x) {
        pos = mid;
        high = mid - 1;        
      } else {
        low = mid + 1;
      }
    }
    cout << f[pos].second << '\n';
  }               
  return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:34:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |       int mid = low + high >> 1;
      |                 ~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 22 ms 5956 KB Output is correct
4 Correct 30 ms 2640 KB Output is correct
5 Correct 55 ms 6400 KB Output is correct
6 Correct 33 ms 5700 KB Output is correct
7 Correct 51 ms 6484 KB Output is correct
8 Correct 50 ms 6568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 22 ms 5956 KB Output is correct
4 Correct 30 ms 2640 KB Output is correct
5 Correct 55 ms 6400 KB Output is correct
6 Correct 33 ms 5700 KB Output is correct
7 Correct 51 ms 6484 KB Output is correct
8 Correct 50 ms 6568 KB Output is correct
9 Correct 0 ms 320 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 324 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 328 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 28 ms 3268 KB Output is correct
24 Correct 35 ms 6612 KB Output is correct
25 Correct 68 ms 9692 KB Output is correct
26 Correct 47 ms 6236 KB Output is correct
27 Correct 44 ms 6724 KB Output is correct
28 Correct 81 ms 10156 KB Output is correct
29 Correct 86 ms 9648 KB Output is correct
30 Correct 56 ms 3872 KB Output is correct
31 Correct 81 ms 10024 KB Output is correct