Submission #812939

# Submission time Handle Problem Language Result Execution time Memory
812939 2023-08-07T11:59:15 Z devariaota Intercastellar (JOI22_ho_t1) C++17
100 / 100
65 ms 10988 KB
#include <bits/stdc++.h>
#define inf INT_MAX
#define longlonginf LONG_LONG_MAX
#define mod  998244353
#define MAXN 200005
#define ll long long
#define deb(x) cerr<<"[ "<<#x<<" = "<<x<<" ]";
#define yes() cout<<"YES\n";
#define no() cout<<"NO\n";
using namespace std;

ll n,m,k,q,x;
ll h;
ll ans = 0;
string subtask;

void solve(){
  cin>>n;
  vector<ll> v;
  vector<ll> va;
  ll a[n+5];
  for(int i = 1 ; i <= n ; i++){
    cin>>a[i];
  }
  v.push_back(0);
  va.push_back(0);
  for(int i = 1 ; i <= n ; i++){
    k = 1;
    while( a[i] % 2 == 0 ){
      k *= 2;
      a[i] /= 2;
    }
    x = v.back();
    v.push_back(x+k);
    va.push_back(a[i]);
  }
  cin>>q;
  while(q--){
    cin>>x;
    ll dist = distance(v.begin(),lower_bound(v.begin(),v.end(),x));
    cout<<va[dist]<<"\n"; 
  }
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  //cin>>T;
  for(int i = 0 ; i < T ; i++){
    //cout<<"Case #"<<i+1<<": ";
    solve();
  }
  return 0;
}

/*
  not i but x
  logical operator
  wrong example/proof
  thoroughly
  wrong variables
  thinking it wrong
  bruh just try some test case
  capitals ;-;
  wrong data structure lol
  count memory usement
  corner case
  oversized array
  orders
  statements
  size initializer
  while con
  map -> array
  wrong digits??
  swapped variables??
  check if theres any variabled
  that got declared twice
  find some pattern
  name collision
  constraints??!
  mod !!
  resets
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 17 ms 5756 KB Output is correct
4 Correct 23 ms 2880 KB Output is correct
5 Correct 40 ms 7228 KB Output is correct
6 Correct 24 ms 5608 KB Output is correct
7 Correct 40 ms 7328 KB Output is correct
8 Correct 40 ms 7340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 316 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 320 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 348 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 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 17 ms 5756 KB Output is correct
4 Correct 23 ms 2880 KB Output is correct
5 Correct 40 ms 7228 KB Output is correct
6 Correct 24 ms 5608 KB Output is correct
7 Correct 40 ms 7328 KB Output is correct
8 Correct 40 ms 7340 KB Output is correct
9 Correct 0 ms 316 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 320 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 25 ms 3528 KB Output is correct
24 Correct 29 ms 6608 KB Output is correct
25 Correct 53 ms 10532 KB Output is correct
26 Correct 35 ms 6776 KB Output is correct
27 Correct 39 ms 6924 KB Output is correct
28 Correct 62 ms 10988 KB Output is correct
29 Correct 59 ms 10408 KB Output is correct
30 Correct 30 ms 4164 KB Output is correct
31 Correct 65 ms 10956 KB Output is correct