Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #pragma warning (disable:4996)
- int main() {
- int t, n;
- scanf("%d", &n);
- scanf("%d", &t);
- t--;
- int* values = new int[n];
- int end = 0, ascendingCount = 0;
- for (int i = 0; i < n; i++, end++) {
- scanf("%d", &values[end]);
- if (end > 0 && values[end - 1] < values[end]) {
- ascendingCount++;
- if (ascendingCount == t) {
- end -= t;
- ascendingCount = 0;
- for (int check = end - t + 1; check >= 0 && check < end; check++) {
- if (values[check - 1] < values[check]) {
- ascendingCount++;
- }
- else {
- ascendingCount = 0;
- }
- }
- end--;
- }
- }
- else {
- ascendingCount = 0;
- }
- }
- for (int i = 0; i < end; i++) {
- printf("%d ", values[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement