Submission #313937

# Submission time Handle Problem Language Result Execution time Memory
313937 2020-10-17T11:21:30 Z Parisa_Razzazi Balloons (CEOI11_bal) C++17
50 / 100
2000 ms 2568 KB
#include <iostream>
#include <iomanip>
using namespace std;
#include <math.h>
#include <vector>
vector <pair<int,long double>> v;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		long double r;
		int x;
		cin >> x;
		cin >> r;
		long double fis;
		int j = v.size()-1;
		long double m = r;
		int ind  = 0;
		bool f = 0;
		while (j >= 0){
			long double o = x - v[j].first;
			fis = o * o / (4 * v[j].second); 
			if (fis < r){
				if (fis < m){
					m = fis;
					ind = v[j].first;
					f = 1;
				}
			}
			j--;
		}
		if (f){
			int p = v.size()-1;
			while (v.size() && v[p].first > ind){
				v.pop_back();
				p--;
			}
		}
		if (v.empty()){
			cout << fixed << setprecision(3) << r << endl;
			v.push_back(make_pair(x,r));
		}
		else{
			cout << fixed << setprecision(3) << m << endl;
			v.push_back(make_pair(x,m));
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 19 ms 512 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 1038 ms 2036 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2079 ms 2440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2043 ms 2568 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2086 ms 2436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2090 ms 2512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2067 ms 2280 KB Time limit exceeded
2 Halted 0 ms 0 KB -