Submission #703572

# Submission time Handle Problem Language Result Execution time Memory
703572 2023-02-27T17:14:58 Z Jeff12345121 Intercastellar (JOI22_ho_t1) C++14
35 / 100
2000 ms 10880 KB
#include <bits/stdc++.h>
#define int long long
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,nr[nmax],val[nmax];

pair<int,int> get_nr(int x) {
    int nr = 1;
    while(x%2 == 0) {
        nr = nr * 2;
        x /= 2;
    }
    return {nr,x};
}
pair<int,int> qs[nmax];
int sol[nmax];
int32_t main() {
    in >> n;
    for (int i = 1; i <= n; i++) {
        in >> a[i];
    }

    for (int i = 1; i <= n; i++) {
        auto v = get_nr(a[i]);
        nr[i] = v.first;
        val[i] = v.second;
        nr[i] += nr[i - 1];
    }

    in >> q;

    for (int i = 1; i <= q; i++) {
        int x;
        in >> x;
        qs[i] = {x, i};
    }
    sort(qs + 1, qs + 1 + q);

    for (int i = 1; i <= q; i++) {
        for (int j = 1; j <= n; j++) {
            if (nr[j] >= qs[i].first) {
                sol[qs[i].second] = val[j];
                break;
            } 
        }
    }

    for (int i = 1; i <= q; i++) {
        out << sol[i] << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1324 ms 5784 KB Output is correct
4 Correct 1360 ms 6456 KB Output is correct
5 Execution timed out 2068 ms 10880 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 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 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1324 ms 5784 KB Output is correct
4 Correct 1360 ms 6456 KB Output is correct
5 Execution timed out 2068 ms 10880 KB Time limit exceeded
6 Halted 0 ms 0 KB -