답안 #531412

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
531412 2022-02-28T15:55:55 Z Cantfindme Balloons (CEOI11_bal) C++17
100 / 100
233 ms 8800 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()

typedef long double ld;
typedef pair<ld,ld> pi;

const int maxn = 200010;
const int INF = LLONG_MAX/2;
const int mod = 1e9+7;

int n;
ld x[maxn], r[maxn];

int32_t main() {
	FAST
	// #ifndef ONLINE_JUDGE
	// 	ifstream cin("input.txt");
	// #endif

	cin >> n;
	for (int i =1;i<=n;i++) cin >> x[i] >> r[i];

	stack <pi> s;
	for (int i =1;i<=n;i++) {
		while (!s.empty()) {
			auto [xp, rp] = s.top(); 
			r[i] = min(r[i], (x[i] - xp) * (x[i] - xp) / (4 * rp));
			if (r[i] >= rp) s.pop();
			else break;
		}
		s.push(pi(x[i], r[i]));
	}

	for (int i =1;i<=n;i++) cout << fixed << setprecision(6) << r[i] << "\n";

}






# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB 505 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB 2000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1108 KB 20000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 2704 KB 50000 numbers
2 Correct 51 ms 2368 KB 49912 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 114 ms 4836 KB 100000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 145 ms 5552 KB 115362 numbers
2 Correct 126 ms 5140 KB 119971 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 185 ms 7208 KB 154271 numbers
2 Correct 212 ms 8388 KB 200000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 230 ms 8800 KB 200000 numbers
2 Correct 233 ms 8352 KB 199945 numbers