Submission #495639

# Submission time Handle Problem Language Result Execution time Memory
495639 2021-12-19T16:40:52 Z keertan Balloons (CEOI11_bal) C++17
10 / 100
149 ms 3300 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<int,int>> z(n);
  for (pair<int,int> &it:z){cin>>it.first>>it.second;}
  stack<pair<double,double>> s;
  for (int i=0;i<n;i++){
    while([&]()->bool{
      if (s.empty()){return false;}
      double x1=s.top().first,y1=s.top().second,x2=z[i].first,y2=z[i].second;
      double dis=((x2-x1)*(x2-x1))/(4.0*y1);
     // cerr<<dis<<" "<<i<<"\n";
      double ans=min(y1,dis);
      return ans>=y1;
    }()){s.pop();}
    if (!s.empty()){
      double x1=s.top().first,y1=s.top().second,x2=z[i].first,y2=z[i].second;
      double dis=((x2-x1)*(x2-x1))/(4.0*y1);
     // cerr<<dis<<" "<<i<<"\n";
      double ans=min(y1,dis);
      cout<<fixed<<setprecision(3)<<ans<<"\n";
      s.emplace(x2,ans);
    }
    else{
      cout<<fixed<<setprecision(3)<<z[i].second<<"\n";
      s.emplace(z[i]);
    }
  }
}
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 lambda function:
bal.cpp:20:63: warning: unused variable 'y2' [-Wunused-variable]
   20 |       double x1=s.top().first,y1=s.top().second,x2=z[i].first,y2=z[i].second;
      |                                                               ^~
bal.cpp: In function 'void solve()':
bal.cpp:27:63: warning: unused variable 'y2' [-Wunused-variable]
   27 |       double x1=s.top().first,y1=s.top().second,x2=z[i].first,y2=z[i].second;
      |                                                               ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB 2nd numbers differ - expected: '252735385.4379999936', found: '1000000000.0000000000', error = '747264614.5620000362'
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 6th numbers differ - expected: '213.0000000000', found: '238.0000000000', error = '25.0000000000'
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB 4th numbers differ - expected: '117.0000000000', found: '120.0020000000', error = '3.0020000000'
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 584 KB 9th numbers differ - expected: '202.0000000000', found: '205.0000000000', error = '3.0000000000'
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 964 KB 3rd numbers differ - expected: '15396.0000000000', found: '15397.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 1860 KB 10th numbers differ - expected: '7926.0000000000', found: '7929.0000000000', error = '3.0000000000'
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 2096 KB 3rd numbers differ - expected: '5055.0000000000', found: '5058.0000000000', error = '3.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 2740 KB 13th numbers differ - expected: '1861.0000000000', found: '1862.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 149 ms 3300 KB 9th numbers differ - expected: '2952.0000000000', found: '2954.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -