Submission #928948

# Submission time Handle Problem Language Result Execution time Memory
928948 2024-02-17T08:43:12 Z doducanh Balloons (CEOI11_bal) C++14
100 / 100
250 ms 7772 KB
#include <bits/stdc++.h>

using namespace std;
#define x first
#define r second
pair<int,int>a[200005];
double ans[200005];
int n;
double cal(pair<double,double>a,double bx)
{
    return double((a.x-bx)*(a.x-bx))/(4*a.r);
}
main()
{
    cin>>n;
    stack<pair<double,double>>s;
    for(int i=1;i<=n;i++){
        double x,r;
        cin>>x>>r;
        double maxr=r;
        while(s.size()){
            double last=cal(s.top(),x);
            maxr=min(maxr,last);
            if(maxr>=s.top().r){
                s.pop();
                continue;
            }
            else break;
        }
        s.push({x,maxr});
        ans[i]=maxr;
    }
    for(int i=1;i<=n;i++)cout<<fixed<<setprecision(3)<<ans[i]<<"\n";
    return 0;
}

Compilation message

bal.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 26 ms 604 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 66 ms 3156 KB 50000 numbers
2 Correct 66 ms 3928 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 125 ms 3556 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 135 ms 3588 KB 115362 numbers
2 Correct 152 ms 5768 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 184 ms 3924 KB 154271 numbers
2 Correct 238 ms 7768 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 240 ms 4116 KB 200000 numbers
2 Correct 250 ms 7772 KB 199945 numbers