Submission #925561

#TimeUsernameProblemLanguageResultExecution timeMemory
925561May27_thBalloons (CEOI11_bal)C++17
100 / 100
140 ms11892 KiB
#include<bits/stdc++.h> #define taskname "A" using namespace std; void World_Final(); void Solve(); int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } World_Final(); } void World_Final(){ int Tests = 1; //cin >> Tests; while (Tests --) { Solve(); } } const int mod = 1e9 + 7; struct ballon{ int64_t x; long double r; }; long double calc(int64_t d, long double r) { return 1.0 * d * d / (4 * r); } void Solve(){ int N; cin >> N; vector<ballon> b(N); for (auto &[x, r] : b) cin >> x >> r; stack<pair<int64_t, long double>> s; for (int i = 0; i < N; i ++) { long double rmax = b[i].r; while (!s.empty()) { long double rmax_last = calc(b[i].x - s.top().first, s.top().second); rmax = min(rmax, rmax_last); if (rmax >= s.top().second) s.pop(); else break; } cout << fixed << setprecision(3) << rmax << "\n"; s.push(make_pair(b[i].x, rmax)); } } /** A = I(i - 1, j), B = I(i, j - 1); |I(i, j)| = |A| + |B| - |A intersect B| **/

Compilation message (stderr)

bal.cpp: In function 'int main()':
bal.cpp:11:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen(taskname".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...