Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define pb push_back
- #define fst first
- #define snd second
- typedef long long ll;
- typedef unsigned long long ull;
- using namespace std;
- typedef pair<int, int> ii;
- typedef pair<int, ii> iii;
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0), cout.tie(0);
- int n, k, l, r;
- cin >> n >> k >> l >> r;
- vector<int> a(n);
- for (int& i : a)
- cin >> i;
- set<ii> t = {{a[0], 0}};
- for (int i = 1; i < n; ++i) {
- auto a_j1 = t.lower_bound({a[i] - r, 0}),
- a_j2 = t.lower_bound({a[i] + l, 0});
- if (a_j1 != t.end() && abs(a[i] - a_j1->fst) >= l && abs(a[i] - a_j1->fst) <= r) {
- cout << a_j1->snd + 1 << ' ' << i + 1;
- return 0;
- } else if (a_j2 != t.end() && abs(a[i] - a_j2->fst) >= l && abs(a[i] - a_j2->fst) <= r) {
- cout << a_j2->snd + 1 << ' ' << i + 1;
- return 0;
- }
- if (i >= k)
- t.erase({a[i - k], i - k});
- t.insert({a[i], i});
- }
- cout << "-1 -1";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement