Submission #278082

#TimeUsernameProblemLanguageResultExecution timeMemory
278082test2Zalmoxis (BOI18_zalmoxis)C++14
0 / 100
119 ms11388 KiB
#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 = 2e9 ; 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)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:42:14: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   42 |   if(l && v[l-1] == ver){
      |             ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...