Submission #534538

# Submission time Handle Problem Language Result Execution time Memory
534538 2022-03-08T08:57:39 Z balbit Intercastellar (JOI22_ho_t1) C++14
100 / 100
69 ms 9160 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pii pair<int, int>
#define f first
#define s second

#define REP(i,n) for (int i = 0; i<n; ++i)
#define REP1(i,n) for (int i = 1; i<=n; ++i)

#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

#define MX(a,b) a = max(a,b)
#define MN(a,b) a = min(a,b)

#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<" "<<#__VA_ARGS__<<" - ", _do(__VA_ARGS__)
template <typename T> void _do( T && x) {cerr<<x<<endl;}
template <typename T, typename ...S> void _do( T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#define endl '\n'
#endif // BALBIT

const int maxn = 3e5+5;

signed main(){
    ios::sync_with_stdio(0), cin.tie(0);

    bug(1,2);

    int n; cin>>n;
    vector<int> a(n);
    vector<int> cnt(n,1);
    REP(i,n) {
        cin>>a[i];
        cnt[i] = a[i] & -a[i];
        a[i] /= cnt[i];
    }
    int q; cin>>q;
    int prv = 1;
    int at = 0;
    while (q--) {
        ll x; cin>>x;
        ll df = x - prv;
        while (df) {
            int tk = min((ll)cnt[at],df);
            cnt[at] -= tk;
            df -= tk;
            if (cnt[at] == 0) ++at;
        }
        cout<<a[at]<<endl;
        prv = x;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 26 ms 3976 KB Output is correct
4 Correct 27 ms 2352 KB Output is correct
5 Correct 40 ms 5512 KB Output is correct
6 Correct 23 ms 4064 KB Output is correct
7 Correct 41 ms 5504 KB Output is correct
8 Correct 48 ms 5532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 26 ms 3976 KB Output is correct
4 Correct 27 ms 2352 KB Output is correct
5 Correct 40 ms 5512 KB Output is correct
6 Correct 23 ms 4064 KB Output is correct
7 Correct 41 ms 5504 KB Output is correct
8 Correct 48 ms 5532 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 320 KB Output is correct
23 Correct 23 ms 3000 KB Output is correct
24 Correct 29 ms 5172 KB Output is correct
25 Correct 58 ms 8684 KB Output is correct
26 Correct 41 ms 5572 KB Output is correct
27 Correct 33 ms 5548 KB Output is correct
28 Correct 69 ms 9160 KB Output is correct
29 Correct 63 ms 8628 KB Output is correct
30 Correct 35 ms 3700 KB Output is correct
31 Correct 65 ms 9068 KB Output is correct