Submission #474145

# Submission time Handle Problem Language Result Execution time Memory
474145 2021-09-17T02:29:37 Z BackNoob Balloons (CEOI11_bal) C++14
40 / 100
514 ms 6484 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 lo = 0 , hi = a[i].r;
	    	double x = s.top().fi;
	    	double r = s.top().se;
	    	for(int j = 1 ; j <= 100 ; j++) {
	    		double mid = (lo + hi) / 2;
	    		if(dist(x , r , a[i].x , mid) >= (r + mid) * (r + mid)) lo = mid;
	    		else hi = mid; 
	    	}
	    	R = min(R , lo);
	    	if(lo >= 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 2 ms 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 900 KB 3437th numbers differ - expected: '298.4460000000', found: '304.0000000000', error = '5.5540000000'
# Verdict Execution time Memory Grader output
1 Correct 143 ms 1824 KB 50000 numbers
2 Incorrect 109 ms 2784 KB 49903rd numbers differ - expected: '443977872.4679999948', found: '1000000000.0000000000', error = '556022127.5320000648'
# Verdict Execution time Memory Grader output
1 Incorrect 261 ms 3524 KB 14857th numbers differ - expected: '7169.6020000000', found: '7176.0000000000', error = '6.3980000000'
# Verdict Execution time Memory Grader output
1 Correct 292 ms 3992 KB 115362 numbers
2 Incorrect 267 ms 6212 KB 119952nd numbers differ - expected: '444418084.8249999881', found: '1000000000.0000000000', error = '555581915.1749999523'
# Verdict Execution time Memory Grader output
1 Incorrect 391 ms 5188 KB 109914th numbers differ - expected: '1404.0970000000', found: '1415.0000000000', error = '10.9030000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 514 ms 6484 KB 8510th numbers differ - expected: '318.4980000000', found: '320.0000000000', error = '1.5020000000'
2 Halted 0 ms 0 KB -