Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <vector>
- #include <stdio.h>
- #include <cmath>
- #include <math.h>
- #include <queue>
- #include <stack>
- #include <climits>
- #include <deque>
- #include <ctime>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef unsigned int ui;
- #define mh() make_heap()
- #define poph() pop_heap()
- #define pushh() push_heap()
- #define sor(n) n.begin(), n.end()
- int main()
- {
- int n;
- scanf("%d", &n);
- vector <unsigned int> h;
- h.reserve(n / 2 + 2);
- unsigned int prom;
- for (int i = 0; i <= n / 2; i++)
- {
- scanf("%ud", &prom);
- h.push_back(prom);
- }
- make_heap(sor(h));
- for (int i = n / 2 + 1; i < n; i++)
- {
- scanf("%ud", &prom);
- if (prom < h[0])
- {
- pop_heap(sor(h));
- h.pop_back();
- h.push_back(prom);
- push_heap(sor(h));
- }
- }
- if (n % 2 == 0)
- {
- prom = h[0];
- pop_heap(sor(h));
- prom += h[0];
- printf("%.1f", prom/2.0);
- }
- else
- {
- printf("%.1f", h[0]*1.0);
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment