Submission #651924

# Submission time Handle Problem Language Result Execution time Memory
651924 2022-10-20T14:09:45 Z womogenes Balloons (CEOI11_bal) C++14
100 / 100
359 ms 10128 KB
// https://oj.uz/problem/view/CEOI11_bal
// Balloons

#include <bits/stdc++.h>
#define x first
#define r second
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<double, double>> balls(n);
  for (int i = 0; i < n; i++) {
    cin >> balls[i].x >> balls[i].r;
  }

  // Stack algorithm
  stack<pair<int, double>> st;
  vector<double> radii(n);

  for (int i = 0; i < n; i++) {
    double max_rad = balls[i].r;

    while (!st.empty()) {
      pair<int, double> top = st.top();
      max_rad = min(pow(balls[i].x - top.x, 2) / (4 * top.r), max_rad);
      if (max_rad >= top.r) {
        st.pop();
      } else {
        break;
      }
    }

    st.push(make_pair(balls[i].x, max_rad));
    radii[i] = max_rad;
  }

  cout << fixed << setprecision(3);
  for (double r : radii) {
    cout << r << "\n";
  }

  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 30 ms 880 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 102 ms 1992 KB 50000 numbers
2 Correct 88 ms 2820 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 174 ms 3604 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 187 ms 4144 KB 115362 numbers
2 Correct 243 ms 6120 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 250 ms 5392 KB 154271 numbers
2 Correct 336 ms 10052 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 317 ms 6584 KB 200000 numbers
2 Correct 359 ms 10128 KB 199945 numbers