Submission #668147

#TimeUsernameProblemLanguageResultExecution timeMemory
668147chanhchuong123Balloons (CEOI11_bal)C++14
100 / 100
145 ms5388 KiB
#include <bits/stdc++.h> using namespace std; #define task "C" #define fi first #define se second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template <typename T1, typename T2> bool mini(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maxi(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false; } const int N = 2e5 + 3; int n; stack<pair<int, double>> st; double calc_r(int x1, double r1, int x2) { return 1.0 * (x2 - x1) * (x2 - x1) / (4 * r1); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin >> n; cout << setprecision(3) << fixed; for (int i = 1; i <= n; i++) { int x, r; cin >> x >> r; double ansi = r; while (st.size()) { mini(ansi, calc_r(st.top().fi, st.top().se, x)); if (st.top().se <= ansi) st.pop(); else break; } st.push({x, ansi}); cout << ansi << '\n'; } }

Compilation message (stderr)

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