Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <fstream>
- using namespace std;
- int main()
- {
- vector <int> a;
- int n = 1000010, k = 100001;
- ifstream d;
- d.open("d2.txt", ios::in);
- for(int i = 0, x; i < n; ++i){
- d >> x;
- a.push_back(x);
- }
- d.close();
- ofstream ans;
- ans.open("ansd2.txt", ios::out);
- vector <int> p;
- for(int i = k / 2; i <= (n - 1) - k / 2; ++i){
- p.clear();
- for (int j = i - k / 2; j <= i + k / 2; ++j){
- p.push_back(a[j]);
- }
- sort(p.begin(), p.end());
- ans << p[k/2 + 1] << " ";
- }
- ans.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement