Submission #1032413

#TimeUsernameProblemLanguageResultExecution timeMemory
1032413nguyendinhanh1508Intercastellar (JOI22_ho_t1)C++17
25 / 100
337 ms524288 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mx 1000007
#define inf LLONG_MAX/20
#define pi pair<int, int>
#define mp make_pair

int a[mx];

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<int> vec;
  for(int i = 0; i < n; i++){
    int count = 1;
    while(a[i] % 2 == 0){
      a[i] /= 2;
      count *= 2;
    }
    for(int j = 0; j < count; j++){
      vec.push_back(a[i]);
    }
  }
  int q;
  cin >> q;
  while(q--){
    int x;
    cin >> x;
    if(x - 1 < vec.size()) cout << vec[x - 1] << '\n';
    else cout << "-1\n";
  }
  return 0; 
}

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:36:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     if(x - 1 < vec.size()) cout << vec[x - 1] << '\n';
      |        ~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...