Submission #642824

# Submission time Handle Problem Language Result Execution time Memory
642824 2022-09-20T15:13:44 Z daria Balloons (CEOI11_bal) C++14
100 / 100
575 ms 14916 KB
#include "bits/stdc++.h"
using namespace std;
#define N (1<<18) // 4194304
#define ld long double
#define x first
#define r second
typedef pair<ld, ld> p;
 
ld rad(p a, p b){
 return (a.x-b.x)*(a.x-b.x)/(4*a.r);
}
 
int main(){
 int n; cin >> n;
 vector<p> v(n);
 vector<ld> r(n);
 for(int i=0; i<n; ++i){ ld a, b; cin >> a >> b; v[i] = {a, b}; }
 stack<p> st;
 for(int i=0; i<n; ++i){
  ld curr = v[i].r;
  while(!st.empty()){
   ld check = rad(st.top(), v[i]);
   curr = min(curr,check);
   if(curr>=st.top().r){ st.pop(); continue; }
   else break;
  }
  r[i] = curr;
  st.push({v[i].x, curr});
 }
 cout << fixed << setprecision(3);
 for(int i=0; i<n; ++i) cout << r[i] << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 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 8 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 56 ms 1368 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 160 ms 3388 KB 50000 numbers
2 Correct 160 ms 2904 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 285 ms 6052 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 327 ms 7048 KB 115362 numbers
2 Correct 336 ms 9000 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 439 ms 9076 KB 154271 numbers
2 Correct 575 ms 14916 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 560 ms 11236 KB 200000 numbers
2 Correct 573 ms 14896 KB 199945 numbers