제출 #703250

#제출 시각아이디문제언어결과실행 시간메모리
703250MilosMilutinovicIntercastellar (JOI22_ho_t1)C++14
100 / 100
86 ms10156 KiB
/**
 *    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;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:34:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |       int mid = low + high >> 1;
      |                 ~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...