Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     ios::sync_with_stdio(false);
  8.     cin.tie(0);
  9.     cout.tie(0);
  10.     cin >> n;
  11.     priority_queue<int> q;
  12.     int i;
  13.     int x;
  14.     for (i = 1;i <= n / 2 + 1;i++) {
  15.         cin >> x;
  16.         q.push(x);
  17.     }
  18.     for (i = n / 2 + 2;i <= n;i++) {
  19.         cin >> x;
  20.         q.push(x);
  21.         q.pop();
  22.     }
  23.     if (n % 2 == 1) {
  24.         cout << q.top();
  25.     }
  26.     else {
  27.         int a = q.top();
  28.         q.pop();
  29.         int b = q.top();
  30.         printf("%.1f", a / 2.0 + b / 2.0);
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement