Submission #534069

# Submission time Handle Problem Language Result Execution time Memory
534069 2022-03-08T00:12:49 Z Paul_Liao_1457 Intercastellar (JOI22_ho_t1) C++17
100 / 100
471 ms 7268 KB
// 還要更強
#include<iostream>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<math.h>
#include<cstring>
#include<stack>
#include<string.h>
#include<random>
#include<algorithm>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define F first
#define S second

using namespace std;

vector<ll> v,ans;
ll pre[200005];

signed main(){
    int n; cin>>n;
    v.pb(0);
    FOR(i,1,n+1){
        int x; cin>>x;
        v.pb(x);
    }
    FOR(i,1,n+1){
        ll tmp=v[i];
        while(tmp%2==0){
            tmp/=2;
        }
        ans.pb(tmp);
        pre[i]=pre[i-1]+v[i]/tmp;
    }
    int q; cin>>q;
    while(q--){
        ll x; cin>>x;
        int l=1,r=n+1,tmp=n+1;
        while(l<r){
            int mid=(l+r)>>1;
            if(pre[mid]>=x){
                tmp=min(tmp,mid);
                r=mid;
            }
            else{
                l=mid+1;
            }
        }
        cout<<ans[tmp-1]<<endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 93 ms 5804 KB Output is correct
4 Correct 250 ms 1808 KB Output is correct
5 Correct 345 ms 5892 KB Output is correct
6 Correct 173 ms 5712 KB Output is correct
7 Correct 367 ms 5872 KB Output is correct
8 Correct 331 ms 5936 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 0 ms 204 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 204 KB Output is correct
7 Correct 1 ms 284 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 93 ms 5804 KB Output is correct
4 Correct 250 ms 1808 KB Output is correct
5 Correct 345 ms 5892 KB Output is correct
6 Correct 173 ms 5712 KB Output is correct
7 Correct 367 ms 5872 KB Output is correct
8 Correct 331 ms 5936 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 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 204 KB Output is correct
15 Correct 1 ms 284 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 3 ms 332 KB Output is correct
23 Correct 212 ms 2424 KB Output is correct
24 Correct 187 ms 5464 KB Output is correct
25 Correct 381 ms 7268 KB Output is correct
26 Correct 255 ms 3992 KB Output is correct
27 Correct 200 ms 5456 KB Output is correct
28 Correct 448 ms 6284 KB Output is correct
29 Correct 442 ms 5932 KB Output is correct
30 Correct 286 ms 1860 KB Output is correct
31 Correct 471 ms 6024 KB Output is correct