답안 #801167

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
801167 2023-08-02T04:52:24 Z vjudge1 Intercastellar (JOI22_ho_t1) C++14
100 / 100
70 ms 7116 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 0 ms 212 KB Output is correct
3 Correct 23 ms 5272 KB Output is correct
4 Correct 29 ms 2020 KB Output is correct
5 Correct 50 ms 5608 KB Output is correct
6 Correct 29 ms 4708 KB Output is correct
7 Correct 49 ms 5584 KB Output is correct
8 Correct 48 ms 5652 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 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 212 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 344 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 0 ms 212 KB Output is correct
3 Correct 23 ms 5272 KB Output is correct
4 Correct 29 ms 2020 KB Output is correct
5 Correct 50 ms 5608 KB Output is correct
6 Correct 29 ms 4708 KB Output is correct
7 Correct 49 ms 5584 KB Output is correct
8 Correct 48 ms 5652 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 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 212 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 344 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 2452 KB Output is correct
24 Correct 31 ms 4696 KB Output is correct
25 Correct 61 ms 7116 KB Output is correct
26 Correct 41 ms 4120 KB Output is correct
27 Correct 35 ms 4636 KB Output is correct
28 Correct 70 ms 6304 KB Output is correct
29 Correct 64 ms 5560 KB Output is correct
30 Correct 36 ms 1816 KB Output is correct
31 Correct 67 ms 6076 KB Output is correct