Submission #414538

# Submission time Handle Problem Language Result Execution time Memory
414538 2021-05-30T15:37:53 Z fahimcp495 Balloons (CEOI11_bal) C++17
100 / 100
194 ms 7768 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n;  cin >> n;
  int x[n];
  double r[n];
  for (int i = 0; i < n; ++i){
    cin >> x[i] >> r[i];
  }
  stack<int> st;
  for (int i = 0; i < n; ++i){
    while (!st.empty()) {
      int dx = x[i]-x[st.top()];
      r[i] = min(r[i], 1.0*dx*dx/(4*r[st.top()]));
      if (r[i] >= r[st.top()]) {
        st.pop();
      } else  break;
    }
    st.push(i);
  }

  cout << fixed << setprecision(3);
  for (int i = 0; i < n; ++i){
    cout << r[i] << "\n";
  }
  
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 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 24 ms 912 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 50 ms 1984 KB 50000 numbers
2 Correct 49 ms 2140 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 102 ms 3516 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 127 ms 3744 KB 115362 numbers
2 Correct 109 ms 4764 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 164 ms 4748 KB 154271 numbers
2 Correct 184 ms 7768 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 194 ms 5396 KB 200000 numbers
2 Correct 184 ms 7756 KB 199945 numbers