제출 #1060611

#제출 시각아이디문제언어결과실행 시간메모리
1060611andrewpIntercastellar (JOI22_ho_t1)C++14
100 / 100
59 ms11384 KiB
//Dedicated to my love, ivaziva
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;
using ll = int64_t;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define dbg(x) cerr << #x << ": " << x << '\n';

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cout.tie(nullptr); cerr.tie(nullptr);

    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<pair<ll, ll>> data;
    data.push_back({0, 0});
    for (ll i = 0; i < n; i++) {
        ll p = a[i];
        while (!(p & 1)) {
            p >>= 1;
        }
        data.push_back({data.back().first + a[i] / p, p});
    }
    ll q;
    cin >> q;
    while (q--) {
        ll x;
        cin >> x;
        ll lb = 0, rb = data.size() - 1, ans = 0;
        while (lb <= rb) {
            int mb = lb + rb >> 1;
            if (data[mb].first >= x) {
                ans = mb;
                rb = mb - 1;
            } else {
                lb = mb + 1;
            }
        }
        cout << data[ans].second << '\n';
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int32_t main()':
Main.cpp:38:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |             int mb = lb + rb >> 1;
      |                      ~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...