Submission #111534

#TimeUsernameProblemLanguageResultExecution timeMemory
111534HideoZalmoxis (BOI18_zalmoxis)C++14
30 / 100
1008 ms263168 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...