Submission #573004

# Submission time Handle Problem Language Result Execution time Memory
573004 2022-06-05T15:44:20 Z groshi Intercastellar (JOI22_ho_t1) C++17
100 / 100
80 ms 11216 KB
#include<iostream>

using namespace std;
#define int long long
int teraz[300000];
int drzewo[1000000];
int pot=1;
int zap(int x,int co)
{
    if(x>pot)
        return teraz[x-pot];
    if(drzewo[x*2]>=co)
        return zap(x*2,co);
    else return zap(x*2+1,co-drzewo[x*2]);
}
int32_t main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n,x;
    cin>>n;
    while(pot<=n)
        pot*=2;
    pot--;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        int ile=1;
        int pom=x;
        while(pom%2==0)
        {
            ile*=2;
            pom/=2;
        }
        drzewo[i+pot]=ile;
        teraz[i]=x/ile;
    }
    for(int i=pot;i>=1;i--)
        drzewo[i]=drzewo[i*2]+drzewo[i*2+1];
    int zapp;
    cin>>zapp;
    while(zapp--)
    {
        cin>>x;
        cout<<zap(1,x)<<"\n";
    }
    return 0;
}
# 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 20 ms 5972 KB Output is correct
4 Correct 30 ms 2816 KB Output is correct
5 Correct 50 ms 7596 KB Output is correct
6 Correct 29 ms 6092 KB Output is correct
7 Correct 50 ms 7564 KB Output is correct
8 Correct 50 ms 7684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
10 Correct 1 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 336 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 20 ms 5972 KB Output is correct
4 Correct 30 ms 2816 KB Output is correct
5 Correct 50 ms 7596 KB Output is correct
6 Correct 29 ms 6092 KB Output is correct
7 Correct 50 ms 7564 KB Output is correct
8 Correct 50 ms 7684 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
18 Correct 1 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 336 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 31 ms 3272 KB Output is correct
24 Correct 33 ms 7212 KB Output is correct
25 Correct 76 ms 10908 KB Output is correct
26 Correct 44 ms 6560 KB Output is correct
27 Correct 43 ms 7564 KB Output is correct
28 Correct 76 ms 11216 KB Output is correct
29 Correct 78 ms 10828 KB Output is correct
30 Correct 42 ms 3948 KB Output is correct
31 Correct 80 ms 11176 KB Output is correct