Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace __gnu_pbds;
- using namespace std;
- typedef long long ll;
- typedef tree <pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
- int main() {
- ios_base::sync_with_stdio(false);
- ordered_set o_set;
- int n, k;
- cin >> n >> k;
- vector<int> v(n);
- for(int i = 0; i < n; i++) {
- cin >> v[i];
- o_set.insert(make_pair(v[i], i));
- if(i >= k) {
- o_set.erase(o_set.lower_bound(make_pair(v[i - k], 0)));
- }
- if(i >= k - 1) {
- cout << (*o_set.find_by_order((k - 1) / 2)).first << " ";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement