Submission #1097429

# Submission time Handle Problem Language Result Execution time Memory
1097429 2024-10-07T09:55:01 Z StillOnQiCondensation Balloons (CEOI11_bal) C++14
100 / 100
375 ms 11464 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define inf 1000000007ll
#define llmax LLONG_MAX
#define pi 3.141592653589793238462643383279502884197169399
 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll ncr(int n, int r)
{
    if (n < r) return 0;
    long long p = 1, k = 1;
    if (n - r < r)
        r = n - r;
    if (r != 0) {
        while (r) {
            p *= n;
            k *= r;
            long long m = __gcd(p, k);
            p /= m;
            k /= m;
            n--;
            r--;
        }
    }
    else
        p = 1;
    return p;
}
 
vector <ll> vcreate(int n){
    vector <ll> v(n);
    for (int i = 0; i < n; i++)
    {
        cin>>v[i];
    }
    return v;
}
int dx[4]{1, -1, 0, 0}, dy[4]{0, 0, 1, -1};
const int MOD=998244353;
ll ModExp(ll x, ll n, ll m) {
	assert(n >= 0);
	x %= m;  // note: m * m must be less than 2^63 to avoid ll overflow
	ll res = 1;
	while (n > 0) {
		if (n % 2 == 1) { res = res * x % m; }
		x = x * x % m;
		n /= 2;
	}
	return res;
}
 
 
 
 
int main()
{
    
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    /* freopen("prime_subtractorization_input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);  */ 
   
    /*  ll T;
    cin>>T;
    
    for(ll oo=0; oo<T; oo++)
    {
   
    } */
 
    int n{};
    cin>>n;
    vector<pair<long double,long double>> v(n);
    vector<long double> fin(n,inf*inf);
 
    for(int i{0}; i<n; i++)
    {
        cin>>v[i].first>>v[i].second;
    }
 
    stack<pair<long double,long double>> st;
    for(int i{0}; i<n; i++)
    {
        fin[i]=v[i].second;
        while(!st.empty())
        {
            long double d=v[i].first-st.top().first;
            fin[i]=min(fin[i],(d*d)/(4*st.top().second)); // max allowed radius till it touches the ballon at the top.
        
            if(fin[i]<st.top().second)
            {
                break;
            }
 
            st.pop();
        }
        st.push({v[i].first,fin[i]});
    }
    cout<<fixed<<setprecision(3);
 
    for(auto u: fin)cout<<u<<endl;
 
   
}
       
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 344 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 4 ms 576 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1528 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 88 ms 3380 KB 50000 numbers
2 Correct 94 ms 3152 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 185 ms 6484 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 201 ms 7056 KB 115362 numbers
2 Correct 204 ms 6736 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 303 ms 9044 KB 154271 numbers
2 Correct 375 ms 11068 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 357 ms 11464 KB 200000 numbers
2 Correct 347 ms 10872 KB 199945 numbers