제출 #624550

#제출 시각아이디문제언어결과실행 시간메모리
624550dooompyIntercastellar (JOI22_ho_t1)C++17
100 / 100
120 ms11024 KiB
#include "bits/stdc++.h"

using namespace std;

void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
    cout << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
    while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
    return o >> a.first >> a.second;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
    return o << '(' << a.first << ", " << a.second << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
    bool is = false;
    for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
    return o << '}';
}

#ifdef local
#define test(args...) abc("[" + string(#args) + "]", args)
#else
#define test(args...) void(0)
#endif

using ll = long long;

ll powers[51];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);
    int n; cin >> n;
    powers[0] = 1;
    for (int i = 1; i <= 50; i++) {
        powers[i] = 2 * powers[i-1];
    }

    vector<ll> stuff;
    vector<ll> orig;

    for (int i = 0; i < n; i++) {
        ll len; cin >> len;
        orig.push_back(len);
        ll lpower = 0;
        for (int j = 50; j >= 0;j --) {
            if (len % powers[j] == 0) {
                lpower = powers[j];
                break;
            }
        }

        stuff.push_back(lpower);
    }

    vector<ll> curstuff(stuff.size());

    for (int i = 0; i < stuff.size(); i++) {
        if (i == 0) curstuff[i] = stuff[i];
        else curstuff[i] = curstuff[i-1] + stuff[i];
//        cout << curstuff[i] << endl;
    }

    int q; cin >> q;
    while (q--) {
        ll fl; cin >> fl;
        int idx = lower_bound(curstuff.begin(), curstuff.end(), fl) - curstuff.begin();
        cout << orig[idx] / stuff[idx] << "\n";
    }
}

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

Main.cpp: In function 'int main()':
Main.cpp:64:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for (int i = 0; i < stuff.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...