Submission #474148

# Submission time Handle Problem Language Result Execution time Memory
474148 2021-09-17T02:36:21 Z BackNoob Balloons (CEOI11_bal) C++14
100 / 100
246 ms 6592 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define endl '\n'
#define mask(i) (1LL << (i))
#define task "name"
#define ull unsigned long long
using namespace std;
const ll mxN = 220797 + 7;
const ll inf = 1e9 + 277;
const ll mod = 2147483648;
const ll infll = 1e18 + 7;
const ll base = 307;
const double eps = 0.001;
 
template <typename T1, typename T2> bool minimize(T1 &a, T2 b) {
	if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maximize(T1 &a, T2 b) {
	if (a < b) {a = b; return true;} return false;
}

struct cicrle{
	int x;
	double r;
} a[mxN];

double ans[mxN];

double dist(double x , double y , double u , double v)
{
	return (x - u) * (x - u) + (y - v) * (y - v);
}

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("task.inp" , "r" , stdin);
    //freopen("task.out" , "w" , stdout);

    int n;
    cin >> n;
    for(int i = 1 ; i <= n ; i++) cin >> a[i].x >> a[i].r;

   	ans[1] = a[1].r;
   	stack<pair<double , double>> s;
   	s.push({a[1].x , a[1].r});
    for(int i = 2 ; i <= n ; i++) {
    	double R = a[i].r;
    	while((int) s.size() != 0) {
	    	double x = s.top().fi;
	    	double r = s.top().se;
	    	R = min(R , 1.0 * (x - a[i].x) * (x - a[i].x) / (4.0 * r));
	    	if(R >= s.top().se) s.pop();
		    else break;
	    }
	    ans[i] = R;
    	s.push({a[i].x , ans[i]});
     }

    for(int i = 1 ; i <= n ; i++) {
    	cout << fixed << setprecision(3) << ans[i] << endl;
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 396 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 21 ms 912 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 54 ms 2056 KB 50000 numbers
2 Correct 57 ms 1816 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 105 ms 3620 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 121 ms 4164 KB 115362 numbers
2 Correct 118 ms 3848 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 174 ms 5444 KB 154271 numbers
2 Correct 190 ms 6232 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 200 ms 6592 KB 200000 numbers
2 Correct 246 ms 6224 KB 199945 numbers