Submission #495904

# Submission time Handle Problem Language Result Execution time Memory
495904 2021-12-20T07:39:17 Z keertan Balloons (CEOI11_bal) C++17
30 / 100
206 ms 4968 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++){
    bool chk=1;
    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=1.0*(1.0*(x1-x)*(x1-x))/(4.0*y1);
        if (chk){z[i].second=min(r,z[i].second);}
        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();}
}

Compilation message

bal.cpp: In function 'void solve()':
bal.cpp:25:29: warning: unused variable 'y' [-Wunused-variable]
   25 |         double x=z[i].first,y=z[i].second,x1=s.top().first,y1=s.top().second;
      |                             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 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 Incorrect 3 ms 332 KB 504th numbers differ - expected: '160.9360000000', found: '163.0000000000', error = '2.0640000000'
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 712 KB 653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000'
# Verdict Execution time Memory Grader output
1 Correct 54 ms 1472 KB 50000 numbers
2 Incorrect 46 ms 2352 KB 49903rd numbers differ - expected: '443977872.4679999948', found: '1000000000.0000000000', error = '556022127.5320000648'
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 2636 KB 14857th numbers differ - expected: '7169.6020000000', found: '7176.0000000000', error = '6.3980000000'
# Verdict Execution time Memory Grader output
1 Incorrect 134 ms 3060 KB 23610th numbers differ - expected: '1467.9600000000', found: '1471.0000000000', error = '3.0400000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 170 ms 3960 KB 12335th numbers differ - expected: '4957.2960000000', found: '4967.0000000000', error = '9.7040000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 206 ms 4968 KB 7553rd numbers differ - expected: '198.8980000000', found: '220.0000000000', error = '21.1020000000'
2 Halted 0 ms 0 KB -