답안 #855197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
855197 2023-09-30T14:56:18 Z ancuber1031 Intercastellar (JOI22_ho_t1) C++14
0 / 100
15 ms 10644 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define p_q priority_queue
#define endl '\n'
#define pb push_back

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n; cin>>n;    
    vector<int> a(n);
    deque<int> ans, ps;
    for (auto& i : a) cin>>i;
    
    while(!a.empty()) {
        int cur = a.back(), cnt = 1;
        a.pop_back();
        while(cur&1^1) {
            cur >>= 1;
            cnt <<= 1;
        }
        ans.push_front(cur);
        ps.push_front(cnt);
    }
    for (int i = 1; i < ps.size(); ++i) ps[i] += ps[i-1];
    
    int q; cin>>q;
    while(q--) {
        int x; cin>>x;
        int l = -1, r = ps.back();
        while(r-l > 1) {
            int mid = (l+r)>>1;
            if (ps[mid] < x) l = mid;
            else r = mid;
        }
        cout<<ans[r]<<endl;
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:21:18: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   21 |         while(cur&1^1) {
      |               ~~~^~
Main.cpp:28:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i = 1; i < ps.size(); ++i) ps[i] += ps[i-1];
      |                     ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 15 ms 10644 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 1 ms 348 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 15 ms 10644 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -