답안 #203091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203091 2020-02-19T10:44:01 Z Neklixx Balloons (CEOI11_bal) C++14
20 / 100
199 ms 7008 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
#define int long long
const double INF = 1e11 + 228;
const int MAXN = 2e5 + 228;
double ans[MAXN];

double intersect1(double x1, double x2, double t1, double t2) {
	//print4(x1, x2, t1, (((x2 / (2 * t2)) - (x1 / (2 * t1))) * 2 * t1 * t2) / (t1 - t2));
	return ((((x2 / (2 * t2)) - (x1 / (2 * t1))) * 2 * t1 * t2) / (t1 - t2));
} 

signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
	int n;
	cin >> n;
	vector<pair<int, int>> v;
	for (int i = 0; i < n; i++) {
		int aa, bb;
		cin >> aa >> bb;
		v.pb({aa, bb});
	}    

	vector<pair<double, double>> s;
	vector<double> x1;
	for (int i = 0; i < n; i++) {
		double now = v[i].S;
		int id = upper_bound(all(x1), (double)v[i].F) - x1.begin();
		/*print2(i, id);
		for (auto oo : s) {
			cout << oo.S << ' ';
		}
		cout << endl;*/
		if (s.size() > 0) {
			assert((int)(s.size()) - id - 1 >= 0);
			//print4("t", s.size(), id, x1.size());
			pair<double, double> to = s[s.size() - id - 1];
			double cl = (to.S * to.S) / (4 * to.F) + (v[i].F * v[i].F) / (4 * to.F) - (2 * v[i].F * to.S) / (4 * to.F);
			now = min(now, cl);
		}
		while (s.size() > 0 && s.back().F <= now) {
			s.pop_back();
		}
		while (x1.size() + 1 > s.size() && s.size() != 0) {
			x1.pop_back();
		}
		if (s.size() == 0) {
			x1.clear();
		}
		while (s.size() >= 2 && x1.back() <= intersect1(s.back().S, (double)v[i].F, sqrt(s.back().F), sqrt(now))) {
			s.pop_back();
			x1.pop_back();
		}
		ans[i] = now;
		//print1(now);
		if (s.size() > 0) {
			x1.pb(intersect1(s.back().S, (double)v[i].F, sqrt(s.back().F), sqrt(now)));
		}
		//print1("ok");
		s.pb({now, (double)v[i].F});
	}

	for (int i = 0; i < n; i++) {
		cout << fixed << setprecision(4) << ans[i] << '\n';
	}
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB 30th numbers differ - expected: '5.5990000000', found: '14.9871000000', error = '9.3881000000'
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 504 KB 114th numbers differ - expected: '39.0180000000', found: '56.0000000000', error = '16.9820000000'
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 1188 KB 196th numbers differ - expected: '100.7250000000', found: '111.0000000000', error = '10.2750000000'
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 2304 KB 7855th numbers differ - expected: '6715.0000000000', found: '6714.9980000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 99 ms 3820 KB 6160th numbers differ - expected: '1173.9560000000', found: '1173.9578000000', error = '0.0018000000'
# 결과 실행 시간 메모리 Grader output
1 Incorrect 114 ms 4328 KB 4588th numbers differ - expected: '54.0000000000', found: '54.0020000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 158 ms 5600 KB 1730th numbers differ - expected: '5.6890000000', found: '6.8052000000', error = '1.1162000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 199 ms 7008 KB 2716th numbers differ - expected: '22.1690000000', found: '43.0000000000', error = '20.8310000000'
2 Halted 0 ms 0 KB -