답안 #805817

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
805817 2023-08-04T00:32:14 Z kebine Intercastellar (JOI22_ho_t1) C++17
100 / 100
59 ms 6272 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define endl "\n"
#define pii pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define pque priority_queue
#define pqueg priority_queue<ll,vector<ll>,greater<ll>>
#define que queue<ll>
#define FOR(m,i,n) for(int i=(m); i<=(n); i++)
#define FORM(m,i,n) for(int i=(m); i>=(n); i--)
#define all(v) sort(v.begin(),v.end())
ll n,q,x,freq;
ll l,r,m,ans;
ll pref[200200];
ll a[200200];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  FOR(1,i,n) {
    cin >> a[i];
    freq = 1;
    while(a[i] % 2 == 0) {
      a[i] /= 2;
      freq *= 2;
    }
    pref[i] = pref[i-1] + freq;
  }
  cin >> q;
  while(q--) {
    cin >> x;
    l = 1;
    r = n;
    while(l <= r) {
      m = (l+r)/2;
      if(pref[m] >= x) {
        ans = a[m];
        r = m - 1;
      }
      else {
        l = m + 1;
      }
    }
    cout << ans << endl;
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 15 ms 3924 KB Output is correct
4 Correct 24 ms 2208 KB Output is correct
5 Correct 39 ms 4628 KB Output is correct
6 Correct 23 ms 3996 KB Output is correct
7 Correct 39 ms 4680 KB Output is correct
8 Correct 44 ms 4680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 328 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 332 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 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 15 ms 3924 KB Output is correct
4 Correct 24 ms 2208 KB Output is correct
5 Correct 39 ms 4628 KB Output is correct
6 Correct 23 ms 3996 KB Output is correct
7 Correct 39 ms 4680 KB Output is correct
8 Correct 44 ms 4680 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 0 ms 328 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 332 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 23 ms 2784 KB Output is correct
24 Correct 27 ms 4224 KB Output is correct
25 Correct 53 ms 6272 KB Output is correct
26 Correct 34 ms 3792 KB Output is correct
27 Correct 32 ms 3924 KB Output is correct
28 Correct 59 ms 5488 KB Output is correct
29 Correct 56 ms 4684 KB Output is correct
30 Correct 34 ms 2284 KB Output is correct
31 Correct 59 ms 5144 KB Output is correct