답안 #808444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
808444 2023-08-05T06:57:29 Z devariaota Intercastellar (JOI22_ho_t1) C++17
100 / 100
74 ms 9160 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pq priority_queue
#define mp make_pair
#define str string
#define ll long long
#define ii pair<int, int>
#define pb push_back
#define MOD 1000000007

using namespace std;

// Feeling stuck? Scroll down for important points! Don't do nothing!
// Don't forget to see constraints, and to comment the cin t if unneccessary

const int N = 2e5+5;
ll a[N], pref[N];

void solve() {
  int n, q;
  cin >> n;
  for (int i=1; i<=n; i++) {
    ll cnt=1;
    
    cin >> a[i];
    if (a[i]%2 == 0) {
      while (a[i] % 2 == 0) {
        a[i]/=2;
        cnt*=2;
      }
    }
    
    pref[i]=pref[i-1] + cnt;
   }
   cin >> q;
   while (q--) {
     ll x, l=1, r=n, res=-1;
     cin >> x;
     while (l<=r) {
       ll mid=(l+r)/2;
       if (pref[mid] >= x) {
         res=a[mid];
         r=mid-1;
      }
      else l=mid+1;
    }
    cout << res << '\n';
  }
   
}

int main() {
  // your code goes here
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int t=1;
  // comment below if no test cases!
//  cout << "INPUT T: " << endl;
//  cin>>t;
  while(t--)
  {
      solve();
  }

  return 0;
}

// Remember to do easier subtasks for ALL problms
// in IO when stuck for too long
// Don't stare at the screen, nothing will come into your mind
// Actively try to view problem from different perspectives
// and or implement them quick if idea is doable
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 16 ms 3968 KB Output is correct
4 Correct 25 ms 2324 KB Output is correct
5 Correct 42 ms 5432 KB Output is correct
6 Correct 24 ms 4064 KB Output is correct
7 Correct 42 ms 5456 KB Output is correct
8 Correct 41 ms 5656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 16 ms 3968 KB Output is correct
4 Correct 25 ms 2324 KB Output is correct
5 Correct 42 ms 5432 KB Output is correct
6 Correct 24 ms 4064 KB Output is correct
7 Correct 42 ms 5456 KB Output is correct
8 Correct 41 ms 5656 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 332 KB Output is correct
12 Correct 0 ms 324 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 26 ms 2976 KB Output is correct
24 Correct 28 ms 5168 KB Output is correct
25 Correct 55 ms 8716 KB Output is correct
26 Correct 38 ms 5684 KB Output is correct
27 Correct 33 ms 5556 KB Output is correct
28 Correct 63 ms 9160 KB Output is correct
29 Correct 60 ms 8640 KB Output is correct
30 Correct 32 ms 3676 KB Output is correct
31 Correct 74 ms 9076 KB Output is correct