# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1103765 |
2024-10-21T16:06:36 Z |
Gourab_ |
Balloons (CEOI11_bal) |
C++17 |
|
153 ms |
15040 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);
nwh=nw;
if(nw<rd){
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 |
336 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
592 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
1360 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
3376 KB |
50000 numbers |
2 |
Correct |
35 ms |
4060 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
6136 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
7236 KB |
115362 numbers |
2 |
Correct |
81 ms |
9036 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
9288 KB |
154271 numbers |
2 |
Correct |
136 ms |
15040 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
153 ms |
11336 KB |
200000 numbers |
2 |
Correct |
126 ms |
14960 KB |
199945 numbers |