답안 #532772

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532772 2022-03-03T20:48:50 Z ioi Intercastellar (JOI22_ho_t1) C++14
100 / 100
81 ms 10736 KB
#include<bits/stdc++.h>

using namespace std;

#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define inF freopen("6in.txt" , "r" , stdin);
#define outF freopen("6.txt" , "w" , stdout);
#define imod(a , n) (a % n + n ) % n
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define scan(v)for(auto &it : v)cin >> it ;
#define ll long long
//#define int ll
#define logar(x , y) log(x) / log(y)
#define __sum(n) n * (n + 1) / 2
#define __lcm(a , b) a / __gcd(a , b) * b
#define pii pair<int , int >
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
const int N =  1e3 + 5 ,  M = N * 64  , MX = 2e4 + 40;
const ll MOD = 1e9 + 7   , oo = 1e9 + 9 , OO = 1e18 , mod = MOD ;
const double pi = acos(-1) , eps = 1e-17 ;

int di[] = {1 , -1 , 0 , 0};
int dj[] = {0 , 0 , -1 , 1};

int n , m ;
//    cin >> n >> m ;






int32_t main()
{   //inF;
    //inF;outF;
    fastio;


    int n ;
    cin >> n ;

    vector<int> v(n);
    for(auto &it : v)cin >> it ;

    int q ;
    cin >> q ;


    vector<pair<ll , int> > Q (q);

    for(int i = 0 ; i < q ; i ++){
        ll a ;
        cin >> a ;
        Q[i] = {a, i};


    }

    sort(Q.begin() ,Q.end());

    int p = 0 ;
    ll sum = 0;



    int ans[q] = {};
    for(int i = 0 ; i < n && p < q;i ++){


        ll cnt = 1 , number = v[i];


        while(number % 2 == 0)cnt *=2 , number /= 2 ;

        sum += cnt ;


        while(p < q && Q[p].first <= sum)ans[Q[p].second] = number , p ++ ;


    }

    for(int i = 0 ; i < q ; i ++)cout << ans[i] << "\n" ;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 31 ms 2468 KB Output is correct
4 Correct 37 ms 4644 KB Output is correct
5 Correct 48 ms 7028 KB Output is correct
6 Correct 27 ms 3908 KB Output is correct
7 Correct 58 ms 7020 KB Output is correct
8 Correct 48 ms 7104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 31 ms 2468 KB Output is correct
4 Correct 37 ms 4644 KB Output is correct
5 Correct 48 ms 7028 KB Output is correct
6 Correct 27 ms 3908 KB Output is correct
7 Correct 58 ms 7020 KB Output is correct
8 Correct 48 ms 7104 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 448 KB Output is correct
23 Correct 34 ms 4972 KB Output is correct
24 Correct 44 ms 5152 KB Output is correct
25 Correct 64 ms 10352 KB Output is correct
26 Correct 44 ms 6160 KB Output is correct
27 Correct 43 ms 5628 KB Output is correct
28 Correct 81 ms 10736 KB Output is correct
29 Correct 75 ms 10160 KB Output is correct
30 Correct 40 ms 6412 KB Output is correct
31 Correct 80 ms 10608 KB Output is correct