代码如下:
'''
#include <iostream>
using namespace std;
int main() {
int n, time,days_can_dance=0;
cin >> n >> time;
int * dance = new int[n]();
for (int i = 0; i < n; i++)
{
cin >> dance[i];
}
int curr_date = time;
while (curr_date < n - time) {
int i = 0;
for (i = 0; i < time;) {
if (dance[curr_date - i] < dance[curr_date - i - 1] || dance[curr_date + i] < dance[curr_date + i + 1])break;
else i++;
}
if (i == time)days_can_dance++;
curr_date++;
}
cout << days_can_dance;
delete []dance;
}