# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
278081 | test2 | Zalmoxis (BOI18_zalmoxis) | C++14 | 117 ms | 11384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define I inline void
using namespace std ;
using ll = long long ;
using ld = long double ;
const int N = 1e5 + 7 ;
// How interesting!
int n , k ;
int main(){
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
//freopen("in.in", "r" , stdin) ;
cin >> n >> k ;
vector< int > v ;
deque<int> dq ;
int mn = 1e9 ;
int j ;
for(int i = 0 ;i < n ;i++){
int x ;
cin >> x ;
v.push_back(x) ;
if(x < mn){
mn = x ;
j = i ;
}
}
dq.push_back(mn) ;
int l = j , r = j;
int ver = mn ;
while(l || r < n - 1 || k ){
if(l && v[l-1] == ver){
ver++ ;
dq.push_front(v[l-1]) ;
l-- ;
}
else if(r < n - 1 && v[r+1] == ver){
ver++ ;
dq.push_back(v[r+1]) ;
r++;
}else if(k){
dq.push_back(ver) ;
ver++ ;
k-- ;
}
else break ;
}
while(dq.size()){
cout<< dq.front() <<" " ;
dq.pop_front() ;
}
return 0 ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |