Submission #1208101

#TimeUsernameProblemLanguageResultExecution timeMemory
1208101pete555Balloons (CEOI11_bal)C++20
30 / 100
144 ms4840 KiB
#include<bits/stdc++.h>
using namespace std;

#define pi pair<int,int>
#define ll long long
#define pb push_back
#define pf push_front

void fileIO(string filename) {
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}

int main()
{
	cin.tie(0)->sync_with_stdio(false);
	//fileIO("");
	int n;
	cin >> n;

	vector<double> ans(n);
	stack<pair<double, double>> S;

	for(int i = 0; i < n; i++) {
		double x, r;
		cin >> x >> r;

		double max_r = r;

		while(S.size()) {
			pair<double, double> a = S.top();

			double b_r = (x - a.first) * (x - a.first) / (4 * a.second);
			max_r = min(max_r, b_r);

			if(b_r >= a.second) {
				S.pop();
				continue;
			}
			else {
				break;
			}
		}

		ans[i] = max_r;
		S.push({x, max_r});
	}

	for(double x : ans) cout << fixed << setprecision(10) << x << '\n';
}

Compilation message (stderr)

bal.cpp: In function 'void fileIO(std::string)':
bal.cpp:10:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         freopen((filename + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:11:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         freopen((filename + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...