제출 #1132844

#제출 시각아이디문제언어결과실행 시간메모리
1132844GrayZalmoxis (BOI18_zalmoxis)C++20
30 / 100
218 ms327680 KiB
#include <bits/stdc++.h> #include <cassert> #include <iomanip> #include <tuple> #include <vector> using namespace std; #define ll int #define ull unsigned long long #define ld long double #define ff first #define ss second #define ln "\n" #define mp make_pair #define INF 2e18 #define MOD 1e9+7 void get(ll x, ll &i, vector<ll> &a, vector<ll> &res, ll &k){ if (i<(ll)a.size() and a[i]==x){ res.push_back(a[i]); i++; return; }else if (k and (i==(ll)a.size() or a[i]>x)){ if (k==1 or x==0){ res.push_back(x); k--; }else{ k--; get(x-1, i, a, res, k); k++; get(x-1, i, a, res, k); } }else{ if (k==0 and i==(ll)a.size()) return; get(x-1, i, a, res, k); get(x-1, i, a, res, k); } } void solve(){ ll n, k; cin >> n >> k; vector<ll> a(n); for (ll i=0; i<n; i++) cin >> a[i]; vector<ll> res; ll point=0; get(30, point, a, res, k); for (auto ch:res) cout << ch << " "; cout << ln; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); auto start = chrono::high_resolution_clock::now(); ll t=1; // cin >> t; while (t--) solve(); #ifdef LOCAL auto duration = chrono::duration_cast<chrono::microseconds>(chrono::high_resolution_clock::now() - start); cout << setprecision(0) << fixed << "time: " << (double)duration.count()/1000.0 << " milliseconds" << endl; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...