Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // WA 3 1306 Timus test
- # include <iostream>
- # include <set>
- # include <algorithm>
- # include <iomanip>
- using namespace std;
- int main() {
- int32_t n;
- int32_t cur_n = 0;
- set<int32_t> m;
- cin >> n;
- for (size_t i = 0; i < n; i++) {
- int32_t a;
- cin >> a;
- m.insert(a);
- cur_n++;
- if (cur_n > 150000) {
- m.erase(m.begin());
- m.erase(m.rbegin());
- cur_n -= 2;
- }
- }
- if (cur_n % 2 == 0) {
- auto it1 = m.begin();
- advance(it1, cur_n / 2 - 1);
- auto it2 = m.begin();
- advance(it2, cur_n / 2);
- int64_t res = (int64_t)*it1 + (int64_t)*it2;
- cout << fixed << setprecision(1) << (double)res / 2.0;
- }
- else {
- auto it1 = m.begin();
- advance(it1, cur_n / 2);
- cout << *it1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement