Submission #566833

# Submission time Handle Problem Language Result Execution time Memory
566833 2022-05-23T02:52:34 Z ind Balloons (CEOI11_bal) C++14
90 / 100
671 ms 8068 KB
#include <bits/stdc++.h>

using namespace std;

void compare(int position1, double radius1, int position2, double &radius2) {
  double current = (double)(position2 - position1) * (double)(position2 - position1) / (4 * radius1);
  if (radius2 - current >= 0.001) radius2 = current;
}

int main() {
  int n;
  cin >> n;
  vector<int> positions(n);
  vector<double> radii(n);
  stack<int> indexes;
  for (int i=0; i<n; i++) {
    cin >> positions[i];
    double radius;
    cin >> radius;
    while (indexes.size() > 0) {
      compare(positions[indexes.top()], radii[indexes.top()], positions[i], radius);
      bool needBreak = radii[indexes.top()] - radius >= 0;
      if (needBreak) break;
      indexes.pop();
    }
    indexes.push(i);
    cout << fixed << setprecision(3);
    cout << radius << endl;
    radii[i] = radius;
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 7 ms 316 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 71 ms 864 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 140 ms 1980 KB 50000 numbers
2 Correct 169 ms 2172 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 294 ms 3788 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 364 ms 4336 KB 115362 numbers
2 Correct 386 ms 5064 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 460 ms 5852 KB 154271 numbers
2 Correct 671 ms 8068 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 603 ms 6860 KB 33740th numbers differ - expected: '3140.9660000000', found: '3140.9690000000', error = '0.0030000000'
2 Halted 0 ms 0 KB -