Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int t;
- cin >> t;
- while(t--) {
- int n, k;
- cin >> n >> k;
- vector<int> a(n);
- for (int i = 0; i < n; i++) {
- cin >> a[i];
- }
- vector<int> arr(n);
- for (int i = 1; i + 1 < n; i++) {
- if (a[i - 1] < a[i] && a[i] > a[i + 1]) {
- arr[i] = 1;
- }
- }
- auto pref = arr;
- for (int i = 1; i < n; i++) {
- pref[i] += pref[i - 1];
- }
- int tmp = 1;
- int l = 1;
- for (int i = 0; i + k <= n; i++) {
- int cur = pref[i + k - 1] - (i > 0 ? pref[i - 1] : 0) + 1 - arr[i] - arr[i + k - 1];
- if (cur > tmp) {
- tmp = cur;
- l = i + 1;
- }
- }
- cout << tmp << ' ' << l << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement