답안 #681709

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681709 2023-01-13T21:02:49 Z sysia Intercastellar (JOI22_ho_t1) C++17
100 / 100
100 ms 6876 KB
//Sylwia Sapkowska
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;

void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long
typedef pair<int, int> T;
const int oo = 1e18, oo2 = 1e9+7, K = 30;
const int mod = 998244353;

void solve(){
    int n; cin >> n;
    vector<T>tab = {{0, 0}};
    int prev = 1;
    for (int i = 1; i<=n; i++){
        int x; cin >> x;
        int k = 1;
        while (x%2 == 0){
            k *= 2;
            x/=2;
        }
        tab.emplace_back(tab.back().first + prev, x);
        prev = k;
    }
    debug(tab);
    int q; cin >> q;
    while (q--){
        int x; cin >> x;
        auto ptr = (int)(upper_bound(tab.begin(), tab.end(), make_pair(x, oo))-tab.begin())-1;
        cout << tab[ptr].second << "\n";
    }
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 20 ms 5076 KB Output is correct
4 Correct 33 ms 2412 KB Output is correct
5 Correct 51 ms 5640 KB Output is correct
6 Correct 31 ms 5068 KB Output is correct
7 Correct 51 ms 5660 KB Output is correct
8 Correct 50 ms 5704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 324 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 212 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 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 20 ms 5076 KB Output is correct
4 Correct 33 ms 2412 KB Output is correct
5 Correct 51 ms 5640 KB Output is correct
6 Correct 31 ms 5068 KB Output is correct
7 Correct 51 ms 5660 KB Output is correct
8 Correct 50 ms 5704 KB Output is correct
9 Correct 0 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 1 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 324 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 212 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 328 KB Output is correct
23 Correct 27 ms 3120 KB Output is correct
24 Correct 38 ms 5536 KB Output is correct
25 Correct 67 ms 6876 KB Output is correct
26 Correct 48 ms 4464 KB Output is correct
27 Correct 44 ms 5340 KB Output is correct
28 Correct 100 ms 6076 KB Output is correct
29 Correct 79 ms 5316 KB Output is correct
30 Correct 42 ms 2944 KB Output is correct
31 Correct 77 ms 6012 KB Output is correct