제출 #1265794

#제출 시각아이디문제언어결과실행 시간메모리
1265794minggaBalloons (CEOI11_bal)C++20
100 / 100
128 ms8276 KiB
// Author: caption_mingle
#include "bits/stdc++.h"

using namespace std;

#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define ll long long
#define ld long double
const int mod = 1e9 + 7;
const int inf = 2e9;
const int N = 2e5 + 7;
int n;
ld ans[N], pos[N];

ld calc(ld x1, ld r1, ld x2) {
	return (x2 - x1) * (x2 - x1) / (4 * r1);
}

signed main() {
	cin.tie(0) -> sync_with_stdio(0);
	#define task ""
	if(fopen(task ".INP", "r")) {
		freopen(task ".INP", "r", stdin);
		freopen(task ".OUT", "w", stdout);
	}
	cin >> n;
	cout << setprecision(3) << fixed;
	vector<int> st;
	for(int i = 1; i <= n; i++) {
		ld x, r; cin >> x >> r;
		ans[i] = r;
		while(sz(st)) {
			int id = st.back();
			ans[i] = min(ans[i], calc(pos[id], ans[id], x));
			if(ans[i] >= ans[id]) st.pop_back();
			else break;
		}
		st.pb(i);
		pos[i] = x;
		cout << ans[i] << ln;
	}
    cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}

컴파일 시 표준 에러 (stderr) 메시지

bal.cpp: In function 'int main()':
bal.cpp:28:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |                 freopen(task ".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:29:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |                 freopen(task ".OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...