답안 #703567

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703567 2023-02-27T17:01:11 Z Jeff12345121 Intercastellar (JOI22_ho_t1) C++14
0 / 100
2000 ms 1684 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
ifstream in("in.in");
ofstream out("out.out");
#else
#define in cin
#define out cout
#endif

const int nmax = 200005;
int n,a[nmax],q;

pair<int,int> get_nr(int x) {
    int nr = 1;
    while(x%2 == 0) {
        nr = nr * 2;
        x /= 2;
    }
    return {nr,x};
}
int answer(int x) {
    for (int i = 1; i <= n; i++) {
        auto val = get_nr(a[i]);
        if (val.first < x) {
            x -= val.first;
        } else {
            return val.second;
        }
    }
    return -1;
}
int main() {
    in >> n;
    for (int i = 1; i <= n; i++) {
        in >> a[i];
    }

    in >> q;

    for (int i = 1; i <= q; i++) {
        int x;
        in >> x;
        out << answer(x) << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Execution timed out 2062 ms 1684 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 4 ms 324 KB Output is correct
9 Incorrect 1 ms 308 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Execution timed out 2062 ms 1684 KB Time limit exceeded
4 Halted 0 ms 0 KB -