Submission #793180

# Submission time Handle Problem Language Result Execution time Memory
793180 2023-07-25T15:16:46 Z peijar Prosjek (COCI18_prosjek) C++17
50 / 50
1 ms 368 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

string to_string(string s) { return s; }
template <typename T> string to_string(T v) {
  bool first = true;
  string res = "[";
  for (const auto &x : v) {
    if (!first)
      res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "]";
  return res;
}

void dbg_out() { cout << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
  cout << ' ' << to_string(H);
  dbg_out(T...);
}

#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

template <class T> using min_pq = priority_queue<T, vector<T>, greater<T>>;

signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  min_pq<double> pq;
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    pq.push(x);
  }

  while (pq.size() > 1) {
    double a = pq.top();
    pq.pop();
    double b = pq.top();
    pq.pop();
    pq.push((a + b) / 2);
  }
  cout << setprecision(15) << fixed << pq.top() << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 368 KB Output is correct