Submission #547047

#TimeUsernameProblemLanguageResultExecution timeMemory
547047mgl_diamondBalloons (CEOI11_bal)C++14
30 / 100
619 ms1644 KiB
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ld = long double;
 
#define ii pair<int, int>
#define dd pair<ld, ld>
#define iii pair<int, ii>
#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << "> " << #x << ": " << x << '\n'
 
template<class T> bool maximize(T&a, T b) { if (a<b) return a=b, 1; return 0; }
template<class T> bool minimize(T&a, T b) { if (a>b) return a=b, 1; return 0; }
 
void setIO(string name="") {
	ios::sync_with_stdio(0); cin.tie(0);
	if (name.size()) freopen((name+".in").c_str(), "r", stdin);
	if (name.size()) freopen((name+".out").c_str(), "w", stdout);
}
 
int n;
stack<dd> st;
 
int main() {
	cin >> n;
	for(int i=0; i<n; ++i) {
		ld x, r; cin >> x >> r;
		while (st.size()) {
			ld x1=st.top().fi, r1=st.top().se;
			ld val=x1-x;
			minimize(r, (val*val)/(4*r1));
			if (r>=r1) st.pop();
			else break;
		}
		st.push({x, r});
		cout << r << " ";
	}
	return 0;
}

Compilation message (stderr)

bal.cpp: In function 'void setIO(std::string)':
bal.cpp:21:26: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  if (name.size()) freopen((name+".in").c_str(), "r", stdin);
      |                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:22:26: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  if (name.size()) freopen((name+".out").c_str(), "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...