답안 #801866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
801866 2023-08-02T08:10:19 Z vjudge1 Intercastellar (JOI22_ho_t1) C++14
100 / 100
82 ms 9224 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std ;
const int N = 2e5 ;
ll n, q, pref[N + 10] ;
vector<pair<ll, ll>> v ;
main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
    cin >> n ;
    v.push_back({0, 0}) ;
    for(ll i = 1 ; i <= n ; i++)
    {
        ll a, kol = 0 ;
        cin >> a ;
        while(!(a & 1))
        {
            kol++ ;
            a >>= 1 ;
        }
        v.push_back({(1 << kol), a}) ;
    }
    cin >> q ;
    for(int i = 1 ; i < v.size() ; i++)
        pref[i] = pref[i - 1] + v[i].fi ;
    while(q--)
    {
        ll x, l = 0, r = v.size() ;
        cin >> x ;
        while(l + 1 < r)
        {
            int mid = (l + r) >> 1 ;
            if(pref[mid] < x)
                l = mid ;
            else
                r = mid ;
        }
        cout << v[r].se << '\n' ;
    }
    return 0 ;
}

Compilation message

Main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 1 ; i < v.size() ; i++)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 19 ms 5616 KB Output is correct
4 Correct 30 ms 2796 KB Output is correct
5 Correct 52 ms 7180 KB Output is correct
6 Correct 29 ms 5440 KB Output is correct
7 Correct 48 ms 7232 KB Output is correct
8 Correct 49 ms 7348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 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 19 ms 5616 KB Output is correct
4 Correct 30 ms 2796 KB Output is correct
5 Correct 52 ms 7180 KB Output is correct
6 Correct 29 ms 5440 KB Output is correct
7 Correct 48 ms 7232 KB Output is correct
8 Correct 49 ms 7348 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 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 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 3404 KB Output is correct
24 Correct 32 ms 6500 KB Output is correct
25 Correct 81 ms 9224 KB Output is correct
26 Correct 39 ms 6136 KB Output is correct
27 Correct 44 ms 6440 KB Output is correct
28 Correct 82 ms 8472 KB Output is correct
29 Correct 77 ms 7736 KB Output is correct
30 Correct 42 ms 3808 KB Output is correct
31 Correct 67 ms 8120 KB Output is correct