답안 #908461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
908461 2024-01-16T12:30:16 Z roimu Balloons (CEOI11_bal) C++14
40 / 100
470 ms 13364 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

bool f(pair<long double, long double> a, pair<long double, long double> b) {
	//そもそも触れなきゃ壊しようがない
	if (b.first - b.second >= a.first + a.second) {
		return b.second >= a.second;
	}

	long double bound = a.first;
	long double two = 2.000000000000000;
	bound += a.second * two;
	return b.first >= bound;
}

long double dist(pair<long double, long double> a, pair<long double, long double> b) {
	long double four = 4.0000000000000000;
	return min((a.first - b.first)*(a.first - b.first) / (four*a.second),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 = a[i].second;
		//小さいうちは潰し続ける、潰したときの半径を覚えておく
		while (!st.empty() and f(st.top(),a[i])) {
			rnow = min(rnow, dist(st.top(), a[i]));
			st.pop();
		}

		if (!st.empty()) {
			rnow = min(rnow, dist(st.top(), a[i]));
		}
		rnow = min(rnow, a[i].second);
		ans[i] = rnow;
		st.push({ a[i].first,rnow });
	}

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

	return 0;
}

/*
2
0 2
20 10

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB 505 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 348 KB 2000 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 1624 KB 3437th numbers differ - expected: '298.4460000000', found: '304.0000000000', error = '5.5540000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 3732 KB 50000 numbers
2 Incorrect 123 ms 3668 KB 49903rd numbers differ - expected: '443977872.4679999948', found: '1000000000.0000000000', error = '556022127.5320000648'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 251 ms 7552 KB 14857th numbers differ - expected: '7169.6020000000', found: '7176.0000000000', error = '6.3980000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 280 ms 8016 KB 115362 numbers
2 Incorrect 329 ms 9164 KB 119952nd numbers differ - expected: '444418084.8249999881', found: '1000000000.0000000000', error = '555581915.1749999523'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 378 ms 10560 KB 109914th numbers differ - expected: '1404.0970000000', found: '1415.0000000000', error = '10.9030000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 470 ms 13364 KB 8510th numbers differ - expected: '318.4980000000', found: '320.0000000000', error = '1.5020000000'
2 Halted 0 ms 0 KB -