Submission #527994

# Submission time Handle Problem Language Result Execution time Memory
527994 2022-02-19T01:12:37 Z amukkalir Intercastellar (JOI22_ho_t1) C++17
100 / 100
100 ms 8920 KB
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll; 

#define prn printf
#define scn scanf

const int nax = 2e5; 
ll p[nax+5]; //jumlahnya 
ll v[nax+5]; // value nya 
int n; 

ll binser(ll x) {
    ll lo = 1, hi = n; 
    ll ret = lo; 

    while(lo <= hi) {
        int mid = (lo+hi)>>1; 
        if(x <= p[mid]) {
            ret = mid; 
            hi = mid-1; 
        } else lo = mid+1; 
    }
    return ret; 
}

signed main () {
    scn("%d", &n); 
    for(int i=1; i<=n; i++) {
        ll a; scn("%lld", &a); 
        int cnt = 0; 
        while(a%2==0) {
            cnt++; 
            a /= 2; 
        }
        p[i] = 1ll<<cnt; 
        p[i] += p[i-1]; 
        v[i] = a; 

        //cerr << i << " " << p[i] << " " << v[i] << endl; 
    }
    int q; 
    scn("%d", &q); 
    
    while(q--) {
        ll x; scn("%lld", &x); 
//cerr << x << " " << binser(x) << endl; 
        prn("%lld\n", v[binser(x)]); 
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scn("%d", &n);
      |        ^
Main.cpp:30:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         ll a; scn("%lld", &a);
      |                  ^
Main.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     scn("%d", &q);
      |        ^
Main.cpp:46:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         ll x; scn("%lld", &x);
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 34 ms 3356 KB Output is correct
4 Correct 39 ms 1228 KB Output is correct
5 Correct 70 ms 3996 KB Output is correct
6 Correct 47 ms 3932 KB Output is correct
7 Correct 68 ms 4980 KB Output is correct
8 Correct 63 ms 5460 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 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 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 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 34 ms 3356 KB Output is correct
4 Correct 39 ms 1228 KB Output is correct
5 Correct 70 ms 3996 KB Output is correct
6 Correct 47 ms 3932 KB Output is correct
7 Correct 68 ms 4980 KB Output is correct
8 Correct 63 ms 5460 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 332 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 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 34 ms 2740 KB Output is correct
24 Correct 43 ms 4788 KB Output is correct
25 Correct 80 ms 8004 KB Output is correct
26 Correct 55 ms 5192 KB Output is correct
27 Correct 46 ms 5040 KB Output is correct
28 Correct 93 ms 8844 KB Output is correct
29 Correct 100 ms 7952 KB Output is correct
30 Correct 48 ms 3524 KB Output is correct
31 Correct 100 ms 8920 KB Output is correct