Submission #495906

# Submission time Handle Problem Language Result Execution time Memory
495906 2021-12-20T07:40:15 Z keertan Balloons (CEOI11_bal) C++17
10 / 100
199 ms 4924 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);r=z[i].second;chk=0;}
        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 Incorrect 0 ms 204 KB 5th numbers differ - expected: '17.1630000000', found: '99.0000000000', error = '81.8370000000'
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 3rd numbers differ - expected: '0.0420000000', found: '3.0000000000', error = '2.9580000000'
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB 114th numbers differ - expected: '39.0180000000', found: '56.0000000000', error = '16.9820000000'
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 716 KB 196th numbers differ - expected: '100.7250000000', found: '111.0000000000', error = '10.2750000000'
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 1488 KB 13945th numbers differ - expected: '0.0140000000', found: '7.0000000000', error = '6.9860000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 119 ms 2692 KB 7236th numbers differ - expected: '0.0070000000', found: '7.0000000000', error = '6.9930000000'
# Verdict Execution time Memory Grader output
1 Incorrect 150 ms 3036 KB 4645th numbers differ - expected: '0.0260000000', found: '8.0000000000', error = '7.9740000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 187 ms 4132 KB 1730th numbers differ - expected: '5.6890000000', found: '6.8060000000', error = '1.1170000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 199 ms 4924 KB 2716th numbers differ - expected: '22.1690000000', found: '43.0000000000', error = '20.8310000000'
2 Halted 0 ms 0 KB -