Submission #843203

# Submission time Handle Problem Language Result Execution time Memory
843203 2023-09-03T19:18:43 Z Elvin_Fritl Zalmoxis (BOI18_zalmoxis) C++17
100 / 100
177 ms 33360 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 66;

vector<int> v[N] , a(N);

void func(int x , int &k){
    if(k == 0 || x == 0){
        cout<<x<<" ";
        return;
    }
    k--;
    func(x-1 ,k);
    func(x-1 ,k);
}

int32_t main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    a[n] = 30;
    int cem = 0;
    for(int i=0;i<n;i++){
        cem += (1<<a[i]);
        assert(k >= 0);
        while(__builtin_ctz(cem) < a[i+1]){
            v[i].push_back(__builtin_ctz(cem));
            cem += (cem & -cem);
            k--;
        }
    }

    for(int i=0;i<n;i++){
        cout << a[i] << " ";
        for(int x : v[i]){
            func(x, k);
        }
    }
    cout<<endl;
    return 0;

}
/*

1 1    2 2    3 3    4 4
1


*/
# Verdict Execution time Memory Grader output
1 Correct 171 ms 29776 KB Output is correct
2 Correct 163 ms 29864 KB Output is correct
3 Correct 163 ms 29776 KB Output is correct
4 Correct 165 ms 29868 KB Output is correct
5 Correct 163 ms 29792 KB Output is correct
6 Correct 170 ms 29924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 164 ms 29780 KB Output is correct
2 Correct 164 ms 29776 KB Output is correct
3 Correct 166 ms 29776 KB Output is correct
4 Correct 164 ms 30032 KB Output is correct
5 Correct 164 ms 29776 KB Output is correct
6 Correct 166 ms 29776 KB Output is correct
7 Correct 177 ms 29804 KB Output is correct
8 Correct 167 ms 29876 KB Output is correct
9 Correct 160 ms 33196 KB Output is correct
10 Correct 102 ms 32336 KB Output is correct
11 Correct 131 ms 33360 KB Output is correct
12 Correct 65 ms 29776 KB Output is correct
13 Correct 64 ms 29780 KB Output is correct
14 Correct 67 ms 29660 KB Output is correct