Submission #954624

# Submission time Handle Problem Language Result Execution time Memory
954624 2024-03-28T08:50:16 Z sleepntsheep Intercastellar (JOI22_ho_t1) C
100 / 100
84 ms 8528 KB
#include<stdio.h>

#define N 200001
int q,n,a[N];
long long t[N];
void upd(int p,long long k){for(;p<N;p|=p+1)t[p]+=k;}
int lb(long long k)
{
    long long val=0,pos=0;
    for(int j=1<<19;j;j>>=1) if(pos+j<=N&&val+t[pos+j-1]<k)pos+=j,val+=t[pos-1];
    return pos;
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        scanf("%d",a+i);
        int c=0;
        while(!(a[i]&1))++c,a[i]>>=1;
        upd(i,1ll<<c);
    }
    scanf("%d",&q);
    while(q--)
    {
        long long x;
        scanf("%lld",&x);
        printf("%d\n",a[lb(x)]);
    }
}

Compilation message

Main.c: In function 'main':
Main.c:16:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d",&n);
      |     ^~~~~~~~~~~~~~
Main.c:19:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%d",a+i);
      |         ^~~~~~~~~~~~~~~
Main.c:24:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d",&q);
      |     ^~~~~~~~~~~~~~
Main.c:28:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%lld",&x);
      |         ^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 29 ms 3176 KB Output is correct
4 Correct 40 ms 2260 KB Output is correct
5 Correct 65 ms 4608 KB Output is correct
6 Correct 38 ms 3420 KB Output is correct
7 Correct 66 ms 4692 KB Output is correct
8 Correct 64 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 432 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 29 ms 3176 KB Output is correct
4 Correct 40 ms 2260 KB Output is correct
5 Correct 65 ms 4608 KB Output is correct
6 Correct 38 ms 3420 KB Output is correct
7 Correct 66 ms 4692 KB Output is correct
8 Correct 64 ms 4948 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 432 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 35 ms 2900 KB Output is correct
24 Correct 40 ms 4692 KB Output is correct
25 Correct 77 ms 7864 KB Output is correct
26 Correct 51 ms 5056 KB Output is correct
27 Correct 45 ms 5132 KB Output is correct
28 Correct 84 ms 8528 KB Output is correct
29 Correct 81 ms 7896 KB Output is correct
30 Correct 48 ms 3668 KB Output is correct
31 Correct 84 ms 8396 KB Output is correct