Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. vector <int> a;
  11. int n = 1000010, k = 100001;
  12.  
  13. ifstream d;
  14. d.open("d2.txt", ios::in);
  15. for(int i = 0, x; i < n; ++i){
  16. d >> x;
  17. a.push_back(x);
  18. }
  19.  
  20. d.close();
  21.  
  22. ofstream ans;
  23. ans.open("ansd2.txt", ios::out);
  24.  
  25. vector <int> p;
  26. for(int i = k / 2; i <= (n - 1) - k / 2; ++i){
  27. p.clear();
  28. for (int j = i - k / 2; j <= i + k / 2; ++j){
  29. p.push_back(a[j]);
  30. }
  31. sort(p.begin(), p.end());
  32. ans << p[k/2 + 1] << " ";
  33. }
  34. ans.close();
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement