Submission #111534

# Submission time Handle Problem Language Result Execution time Memory
111534 2019-05-15T14:37:15 Z Hideo Zalmoxis (BOI18_zalmoxis) C++14
30 / 100
1000 ms 263168 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define vl vector < ll >
#define pi pair < int, int >
#define pl pair < ll, ll >
#define pii pair < int, pi >
#define vii vector < pi >

const int N = 1e6 + 7;
const int INF = 1e9;

int a[N];
int n, k, it;

vector < int > ans;


void waste (int val){
    if (val == 0)
        ans.pb(0);
    else if (k){
        k--;
        waste(val - 1);
        waste(val - 1);
    }
    else
        ans.pb(val);
}

void build (int val = 30){
    if (a[it] == val && it <= n){
        it++;
        ans.pb(val);
    }
    else if (a[it] > val || it > n){
        k--;
        waste(val);
    }
    else if (val != 0){
        build(val - 1);
        build(val - 1);
    }
    else
        ans.pb(0);
}

main(){
    it++;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    build();
    for (int out : ans)
        printf("%d ", out);
}

Compilation message

zalmoxis.cpp:54:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:58:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 211 ms 12380 KB Output is correct
2 Correct 200 ms 12380 KB Output is correct
3 Correct 248 ms 12604 KB Output is correct
4 Correct 175 ms 12384 KB Output is correct
5 Correct 177 ms 12508 KB Output is correct
6 Correct 190 ms 12380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 500 ms 39232 KB Expected EOF
2 Incorrect 350 ms 23000 KB Expected EOF
3 Incorrect 293 ms 22876 KB Expected EOF
4 Execution timed out 1008 ms 72088 KB Time limit exceeded
5 Incorrect 296 ms 22872 KB Expected EOF
6 Incorrect 457 ms 31008 KB Expected EOF
7 Incorrect 514 ms 39416 KB Expected EOF
8 Incorrect 235 ms 15692 KB Expected EOF
9 Runtime error 631 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 655 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 630 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 926 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 954 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 936 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)