Submission #890733

#TimeUsernameProblemLanguageResultExecution timeMemory
890733TimAniBalloons (CEOI11_bal)C++17
100 / 100
162 ms11156 KiB
#include <algorithm> #include <cassert> #include <cstdio> #include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <numeric> #include <stack> #include <queue> #include <cmath> #include <array> #include <iomanip> using namespace std; void setIO(string File_name) { cin.tie(0)->sync_with_stdio(0); if (File_name.size()) { freopen((File_name + ".in").c_str(), "r", stdin); freopen((File_name + ".out").c_str(), "w", stdout); } } const long double eps = 1e-9; void sol() { int n; cin >> n; vector<pair<double, double>> v(n); for(int i = 0; i < n; i++) cin >> v[i].first >> v[i].second; vector<double> ans(n); auto radius = [&](int curr, pair<double, double> prev) -> double { double r = (v[curr].first - prev.first) * ((v[curr].first - prev.first)) / (4 * prev.second); return r; }; stack<pair<double, double>> mono; for(int i = 0; i < n; i++){ double R = v[i].second; while(!mono.empty()){ pair<double, double> t = mono.top(); double r = radius(i, t); R = min(R, r); if(R >= t.second){ mono.pop(); continue; } else break; } mono.push(make_pair(v[i].first, R)); ans[i] = R; } for(auto el : ans){ cout << fixed << setprecision(6) << el << ' '; } } int main() { setIO(""); int T = 1; //cin >> T; while (T--) sol(); return 0; }

Compilation message (stderr)

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