Submission #853095

# Submission time Handle Problem Language Result Execution time Memory
853095 2023-09-23T12:17:21 Z Youssif_Elkadi Balloons (CEOI11_bal) C++17
70 / 100
242 ms 3084 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 3, mod = 1e9 + 7, inf = 1e9 + 5;
double dist(double x1, double y1, double x2, double y2)
{
   return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
double gimr(double x1, double y1, double x2, double y2)
{
   double l = 0, r = y2, mid, ans = 0;
   while ((r - l) > 1e-6)
   {
      mid = (l + r) / 2;
      if (dist(x1, y1, x2, mid) >= y1 + mid)
         ans = max(ans, mid), l = mid;
      else
         r = mid;
   }
   return ans;
}
bool sa7be(double x1, double y1, double x2, double y2)
{
   return (y1 + y2 > dist(x1, y1, x2, y2));
}
int main()
{
   ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
   int n;
   cin >> n;
   stack<pair<double, double>> st;
   for (int i = 0; i < n; i++)
   {
      double x, r;
      cin >> x >> r;
      while (true)
      {
         if (st.size() && sa7be(st.top().first, st.top().second, x, r))
            r = min(r, gimr(st.top().first, st.top().second, x, r));
         if (st.size() && r > st.top().second)
            st.pop();
         else
            break;
      }
      cout << fixed << setprecision(3) << r << "\n";
      st.push({x, r});
   }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 23 ms 600 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 60 ms 1048 KB 50000 numbers
2 Correct 51 ms 1104 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 164 ms 1440 KB 70336th numbers differ - expected: '7253.0080000000', found: '7253.0100000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 148 ms 1476 KB 46289th numbers differ - expected: '13173.6530000000', found: '13173.6510000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 195 ms 1780 KB 154271 numbers
2 Correct 206 ms 3084 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 242 ms 1872 KB 166658th numbers differ - expected: '3686.9220000000', found: '3686.9200000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -