Easy problem and I directly attached to the code.
#include <stdio.h>
#include <iostream>
using namespace std;
#define LEN 1000
int mon[LEN];
int index[LEN];
int main() {
int n, k, tmp;
int i, count;
scanf("%d%d", &n, &k);
for(i = 0; i < 2*n+1; i++) {
scanf("%d", &mon[i]);
}
count = 0;
if(mon[0] > mon[1]+1) {
index[count++] = 0;
}
for(i = 1; i < 2*n; i++) {
if((mon[i] > mon[i-1]+1) && (mon[i] > mon[i+1]+1)) {
index[count++] = i;
}
}
tmp = 0;
for(i = 0; i < 2*n+1; i++) {
if(i == index[tmp] && tmp < k) {
printf("%d ", mon[index[tmp++]]-1);
}
else {
printf("%d ", mon[i]);
}
}
printf("\n");
return 0;
}