Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 1000;
- int arr[N + 1];
- int main(){
- int nNumber, cut;
- scanf("%d%d", &nNumber, &cut);
- for(int i = 1; i <= nNumber; ++i){
- scanf("%d", &arr[i]);
- }
- int len = nNumber - cut;
- int cnt = 0;
- int i = 1;
- while(cnt < len){
- int mn = 1e9;
- int mnIdx = i;
- for(int j = i; j <= i + cut; ++j){
- if(arr[j] < mn){
- mn = arr[j];
- mnIdx = j;
- }
- }
- cout << mn << ' ';
- cut -= mnIdx - i;
- i = mnIdx + 1;
- ++cnt;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement