Submission #945457

# Submission time Handle Problem Language Result Execution time Memory
945457 2024-03-13T20:19:30 Z nolqf Balloons (CEOI11_bal) C++14
100 / 100
154 ms 11672 KB
#include <bits/stdc++.h>

using namespace std;
using ld = long double;

const int DIM = 2e5 + 5;

ld x[DIM], r[DIM];

inline ld get( int i, int j ) {
  return (x[i] - x[j]) * (x[i] - x[j]) / (4.0 * r[j]);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;

  cin >> n;
  for ( int i = 1; i <= n; ++i ) {
	cin >> x[i] >> r[i];
  }
  vector<int> stk;
  for ( int i = 1; i <= n; ++i ) {
	while ( stk.size() ) {
	  r[i] = min(r[i], get(i, stk.back()));
      if ( r[i] < r[stk.back()] ) break;
	  stk.pop_back();
	}
	stk.push_back(i);
  }

  cout << fixed << setprecision(3);
  for ( int i = 1; i <= n; ++i ) {
	cout << r[i] << "\n";
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 16 ms 4700 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 40 ms 5212 KB 50000 numbers
2 Correct 37 ms 5804 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 79 ms 5968 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 91 ms 6492 KB 115362 numbers
2 Correct 87 ms 8532 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 123 ms 7252 KB 154271 numbers
2 Correct 152 ms 11672 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 153 ms 8268 KB 200000 numbers
2 Correct 154 ms 11620 KB 199945 numbers