Submission #917151

#TimeUsernameProblemLanguageResultExecution timeMemory
917151FucKanhBalloons (CEOI11_bal)C++14
100 / 100
126 ms8588 KiB
#include<bits/stdc++.h> using namespace std; void IOfile(string name) { freopen((name + ".inp").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } pair<double,double> a[200005]; stack<int> st; double findr(pair<int, double> a, double bx) { return (a.first - bx) * (a.first - bx) / (4 * a.second); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // IOfile("TEST"); int n; cin >> n; for (int i =0 ; i <n;i++) { int x,r; cin >> x >> r; a[i] = {x,r}; } st.push(0); for (int i = 1; i < n; i++) { while (st.size()) { a[i].second=min(a[i].second, findr(a[st.top()], a[i].first)); if (a[st.top()].second <= a[i].second) { st.pop(); } else break; } st.push(i); } for (int i = 0; i < n; i++) cout << fixed << setprecision(3) << a[i].second << "\n"; return 0; }

Compilation message (stderr)

bal.cpp: In function 'void IOfile(std::string)':
bal.cpp:5:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |     freopen((name + ".inp").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:6:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     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...