Submission #1103762

# Submission time Handle Problem Language Result Execution time Memory
1103762 2024-10-21T15:55:55 Z Gourab_ Balloons (CEOI11_bal) C++17
10 / 100
145 ms 14164 KB
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


typedef long long ll;
typedef long double ld;
typedef tree<
ll,
null_type,
less_equal<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define db double
#define pii pair<ll,ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b,c) for(ll i=a;i<b;i+=c)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define fri(i,a,b,c) for(ll i=a;i>=b;i-=c)
#define pb push_back
#define ss second
#define ff first
#define in insert
#define sq(x)  (x*x)
#define all(a)  a.begin(),a.end()
#define nl '\n'
#define npii pair<ll,pair<ll,ll>>
#define mnpq  priority_queue <npii, vector<npii>, greater<npii> >

ll gcd(ll a,ll b){
       if(b==0)return a;
       return gcd(b,a%b);
}
int getRandom(int L,int R)
{
    return rng()%(R-L+1) + L;
}

ll lcm(ll a,ll b){
       return ((a)/gcd(a,b))*b;
}

ll bigmod(ll a,ll n,ll md){
       if(n==0){
           return 1;
       }
       if(n==1){
           return a%md;
       }
       ll d= bigmod(a,n/2,md);
       if(n%2==0){
           return (d*d)%md;
       }
       else{
           return ( ((d*d)%md) * (a%md) )%md;
       }
}

bool sortbysec(const pair<int,int> &a,
            const pair<int,int> &b)
{

    if(a.first==b.first){
         return (a.second > b.second);
    }

    return (a.first< b.first);
}


const ll  N = 200004;
const ll mod = 1e9 + 7;

const ll neginf= -1e18;
const ll inf = 1e18;
const ld eps= 1e-9;


/// avoid Wrong answer
/// think 2 minute before submission
/// check input output before submission
///use binary search for maximum minimum problem


ll sqr(ll d){
   return d*d;
 }



void solve(){

    ll n;
    cin>>n;
    ld x[n],r[n];
    ld ans[n];

    f(i,0,n){
      cin>>x[i]>>r[i];
    }

    ld val;
    stack<pair<ld,ld> >st;

    f(i,0,n){
        if(i==0){

          st.push({x[i],r[i]});
          ans[i]=r[i];
        }
        else{
              ld nwh=r[i];

              pair<ld,ld>ab;

              while(!st.empty()){
                  ab=st.top();
                  ld rd=ab.ss;
                  ld dis=x[i]-ab.ff;
                  ld nw= (dis*dis)/(4.0*rd);

                  nw=min(nw,nwh);

                  if(nw<rd){
                    nwh=nw;
                    break;
                  }
                  else{
                    st.pop();
                  }

              }

              ans[i]=nwh;
              st.push({x[i],nwh});

        }
    }

    cout<<fixed<<setprecision(3);
    f(i,0,n){
        cout<<ans[i]<<nl;
    }








}
int main(){

       ios_base::sync_with_stdio(false);
       cin.tie(NULL);
       cout.tie(NULL);

        ll t=1;
      // cin>>t;
        while(t--){
             solve();
        }


}

Compilation message

bal.cpp: In function 'void solve()':
bal.cpp:108:8: warning: unused variable 'val' [-Wunused-variable]
  108 |     ld val;
      |        ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 504 KB 2nd numbers differ - expected: '252735385.4379999936', found: '1000000000.0000000000', error = '747264614.5620000362'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB 6th numbers differ - expected: '213.0000000000', found: '238.0000000000', error = '25.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 596 KB 79th numbers differ - expected: '36.0070000000', found: '2766.0000000000', error = '2729.9930000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 1620 KB 137th numbers differ - expected: '67.1010000000', found: '3129.0000000000', error = '3061.8990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 3924 KB 250th numbers differ - expected: '15134.0000000000', found: '18307.0000000000', error = '3173.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 7456 KB 162nd numbers differ - expected: '7765.0000000000', found: '14571.0000000000', error = '6806.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 8532 KB 510th numbers differ - expected: '4505.0010000000', found: '13465.0000000000', error = '8959.9990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 112 ms 11340 KB 161st numbers differ - expected: '1703.0000000000', found: '4036.0000000000', error = '2333.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 145 ms 14164 KB 248th numbers differ - expected: '2694.0020000000', found: '8658.0000000000', error = '5963.9980000000'
2 Halted 0 ms 0 KB -