Submission #474144

# Submission time Handle Problem Language Result Execution time Memory
474144 2021-09-17T02:27:49 Z BackNoob Balloons (CEOI11_bal) C++14
20 / 100
515 ms 9284 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++) {
    	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; 
	    	}
	    	ans[i] = lo;
	    	if(lo >= s.top().se) s.pop();
		    else break;
	    }
    	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 1 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB 14th numbers differ - expected: '2.6090000000', found: '7.1410000000', error = '4.5320000000'
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB 79th numbers differ - expected: '36.0070000000', found: '2766.0000000000', error = '2729.9930000000'
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 1116 KB 137th numbers differ - expected: '67.1010000000', found: '3129.0000000000', error = '3061.8990000000'
# Verdict Execution time Memory Grader output
1 Incorrect 131 ms 2600 KB 250th numbers differ - expected: '15134.0000000000', found: '18307.0000000000', error = '3173.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 261 ms 4936 KB 162nd numbers differ - expected: '7765.0000000000', found: '14571.0000000000', error = '6806.0000000000'
# Verdict Execution time Memory Grader output
1 Incorrect 317 ms 5620 KB 510th numbers differ - expected: '4505.0010000000', found: '13465.0000000000', error = '8959.9990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 407 ms 7452 KB 161st numbers differ - expected: '1703.0000000000', found: '4036.0000000000', error = '2333.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 515 ms 9284 KB 248th numbers differ - expected: '2694.0020000000', found: '8658.0000000000', error = '5963.9980000000'
2 Halted 0 ms 0 KB -