Submission #908575

# Submission time Handle Problem Language Result Execution time Memory
908575 2024-01-16T14:41:14 Z roimu Balloons (CEOI11_bal) C++14
10 / 100
2000 ms 9784 KB
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
#include <assert.h>

using namespace std;

typedef long long LL;
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

long double dist(pair<long double, long double> a, pair<long double, long double> b) {
	long double four = 4.0000000000000000;
	return (a.first - b.first)*(a.first - b.first) / four / a.second;
}

long double getr(pair<long double, long double> a, pair<long double, long double> b) {
	return min(dist(a, b), b.second);
}


int main() {
	int n; cin >> n;
	vector<pair<long double, long double>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}

	vector<long double> ans(n);
	ans[0] = a[0].second;
	stack<pair<long double, long double>> st;
	st.push(a[0]);
	for (int i = 1; i < n; i++) {
		long double rnow = 10000000000;
		while (!st.empty()) {
			long double rb = getr(st.top(), a[i]);
			rnow = min(rnow, rb);
			if (rb >= st.top().second) {
				st.pop();
			}
		}

		if (st.empty()) {
			st.push({ a[i].first,rnow });
		}
		else {
			long double rb= getr(st.top(), a[i]);
			rnow = min(rnow, rb);
			st.push({ a[i].first,rnow });
		}

		ans[i] = rnow;
	}

	for (int i = 0; i < n; i++) {
		cout << fixed << setprecision(3) << ans[i] << endl;
	}

	return 0;
}

/*
2
0 2
20 10

*/
# Verdict Execution time Memory Grader output
1 Execution timed out 2024 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2050 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2055 ms 1372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2056 ms 2760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2039 ms 5120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2066 ms 5836 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2025 ms 7572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2058 ms 9784 KB Time limit exceeded
2 Halted 0 ms 0 KB -