Submission #824342

# Submission time Handle Problem Language Result Execution time Memory
824342 2023-08-14T03:31:14 Z Amylopectin Intercastellar (JOI22_ho_t1) C++14
100 / 100
57 ms 8416 KB
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
const long long mxn = 1e6 + 10;
long long val[mxn] = {},npie[mxn] = {},len[mxn] = {},ans[mxn] = {};
int main()
{
    long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cru;
    scanf("%lld",&n);
    for(i=0; i<n; i++)
    {
        scanf("%lld",&val[i]);
        npie[i] = 1;
        len[i] = val[i];
        for(j=0; j<50; j++)
        {
            if(1 & len[i])
            {
                break;
            }
            else 
            {
                npie[i] <<= 1;
                len[i] >>= 1;
            }
        }
        if(i > 0)
            npie[i] += npie[i-1];
    }
    scanf("%lld",&m);
    cru = 0;
    for(i=0; i<m; i++)
    {
        scanf("%lld",&cn);
        while(cn > npie[cru])
        {
            cru ++;
        }
        ans[i] = len[cru];
        // printf("%lld\n",len[cru]);
    }
    for(i=0; i<m; i++)
    {
        printf("%lld\n",ans[i]);
    }

}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:9:26: warning: unused variable 'cm' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cru;
      |                          ^~
Main.cpp:9:29: warning: unused variable 'fn' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cru;
      |                             ^~
Main.cpp:9:32: warning: unused variable 'fm' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cru;
      |                                ^~
Main.cpp:9:35: warning: unused variable 'cl' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cru;
      |                                   ^~
Main.cpp:9:38: warning: unused variable 'cr' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cru;
      |                                      ^~
Main.cpp:9:41: warning: unused variable 'mid' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cru;
      |                                         ^~~
Main.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
Main.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%lld",&val[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%lld",&m);
      |     ~~~~~^~~~~~~~~~~
Main.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         scanf("%lld",&cn);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 19 ms 5168 KB Output is correct
4 Correct 25 ms 2892 KB Output is correct
5 Correct 42 ms 6952 KB Output is correct
6 Correct 25 ms 5168 KB Output is correct
7 Correct 42 ms 6860 KB Output is correct
8 Correct 41 ms 6872 KB Output is correct
# 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 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
10 Correct 0 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 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 19 ms 5168 KB Output is correct
4 Correct 25 ms 2892 KB Output is correct
5 Correct 42 ms 6952 KB Output is correct
6 Correct 25 ms 5168 KB Output is correct
7 Correct 42 ms 6860 KB Output is correct
8 Correct 41 ms 6872 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 22 ms 3204 KB Output is correct
24 Correct 32 ms 4992 KB Output is correct
25 Correct 52 ms 8416 KB Output is correct
26 Correct 33 ms 4756 KB Output is correct
27 Correct 30 ms 4768 KB Output is correct
28 Correct 57 ms 7628 KB Output is correct
29 Correct 55 ms 6968 KB Output is correct
30 Correct 29 ms 2732 KB Output is correct
31 Correct 57 ms 7368 KB Output is correct