Submission #495642

# Submission time Handle Problem Language Result Execution time Memory
495642 2021-12-19T16:57:27 Z keertan Balloons (CEOI11_bal) C++17
100 / 100
271 ms 8556 KB
#include <bits/stdc++.h>
using namespace std;
//#define int  int64_t
#define all(x) x.begin(), x.end()
#define all1(x) x.rbegin(), x.rend()
#define sz(x) (int)(x.size())
const int N = 1e5 + 5, mod = 1e9 + 7;
const int64_t N1=1e18;
const double eps=1e-11;
//#define double long double
void solve(){
  int n;
  cin>>n;
  vector<pair<double,double>> z(n);
  for (pair<double,double> &it:z){cin>>it.first>>it.second;}
  stack<pair<double,double>> s;
  for (int i=0;i<n;i++){
    while(1){
      if (s.empty()){
        s.emplace(z[i].first,z[i].second);
        break;
      }
      else{
        double x=z[i].first,y=z[i].second,x1=s.top().first,y1=s.top().second;
        double r=min(y*1.0,1.0*(1.0*(x1-x)*(x1-x))/(4.0*y1));
        z[i].second=r;
        if (r>=y1){s.pop();}
        else{
          s.emplace(z[i].first,z[i].second);
          break;
        }
      }
    }
    cout<<fixed<<setprecision(3)<<s.top().second<<"\n";
  }
}
int32_t main(){
  ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
  int tq = 1;
  //cin>>tq;
  for (;tq;tq--){solve();}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 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 368 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 30 ms 772 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 77 ms 1584 KB 50000 numbers
2 Correct 54 ms 2352 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 110 ms 2764 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 124 ms 3264 KB 115362 numbers
2 Correct 118 ms 5256 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 245 ms 4136 KB 154271 numbers
2 Correct 271 ms 8480 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 238 ms 4972 KB 200000 numbers
2 Correct 195 ms 8556 KB 199945 numbers