Submission #702807

# Submission time Handle Problem Language Result Execution time Memory
702807 2023-02-25T08:01:08 Z Truitadepatates Balloons (CEOI11_bal) C++14
100 / 100
192 ms 7020 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  cout << fixed << setprecision(3);
  vector<double> ans(n);
  stack<pair<double, double>> balloons;
  double x, r;
  double rmax, mmax;
  for (int i = 0; i < n; i++){
    cin >> x >> r;
    mmax = 0;
    rmax = r;
    if (i == 0){
      ans[0] = r;
      balloons.push({x, r});
    }
    else{
      while (!balloons.empty()){
        mmax = ((x-balloons.top().first)*(x-balloons.top().first))/(4*balloons.top().second);
        if (mmax < rmax){
          rmax = mmax;
        }
        if (rmax >= balloons.top().second){
          balloons.pop();
        }
        else{
          break;
        }
      }
      balloons.push({x, rmax});
      ans[i] = rmax;
    }
  }
  for (int i = 0; i < n; i++){
    cout << ans[i] << "\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 1 ms 316 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 19 ms 888 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 50 ms 1984 KB 50000 numbers
2 Correct 52 ms 1924 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 100 ms 3500 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 135 ms 3980 KB 115362 numbers
2 Correct 115 ms 4332 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 156 ms 5172 KB 154271 numbers
2 Correct 183 ms 6948 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 192 ms 6168 KB 200000 numbers
2 Correct 175 ms 7020 KB 199945 numbers