Submission #651563

# Submission time Handle Problem Language Result Execution time Memory
651563 2022-10-19T10:50:10 Z Melika0gh Balloons (CEOI11_bal) C++17
100 / 100
343 ms 8524 KB
#include<bits/stdc++.h>
using namespace std;

const int maxn = 2e5+10;
double x[maxn], r[maxn];
vector<int> st;
int n;

void FindR(int ind)
{
	int i = st.back();
	double tmpr = (x[ind] - x[i]) / (double(4) * r[i]);
	tmpr *= (x[ind] - x[i]);
	//cout << ind << " , " << i << " , " << tmpr << endl;
	r[ind] = min(r[ind], tmpr);
}

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> x[i] >> r[i];
	}
	
	for(int i = 0; i < n; i++)
	{
		while(!st.empty())
		{
			FindR(i);
			if(r[i] >= r[st.back()])
			{
				st.pop_back();
			}
			else
				break;
		}
		
		st.push_back(i);
	}
	
	for(int i = 0; i < n; i++)
	{
		cout.precision(3);
		cout << fixed << r[i] << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 316 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 35 ms 944 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 86 ms 2276 KB 50000 numbers
2 Correct 85 ms 2328 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 168 ms 4184 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 188 ms 4856 KB 115362 numbers
2 Correct 203 ms 5216 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 246 ms 6348 KB 154271 numbers
2 Correct 342 ms 8516 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 302 ms 7656 KB 200000 numbers
2 Correct 343 ms 8524 KB 199945 numbers