Submission #1236411

#TimeUsernameProblemLanguageResultExecution timeMemory
1236411enxiayyBalloons (CEOI11_bal)C++20
100 / 100
149 ms4996 KiB
#include <bits/stdc++.h> #define fi first #define se second #define all(x) x.begin(), x.end() #define compact(v) v.erase(unique(all(v)), v.end()) #define dbg(v) "[" #v " = " << (v) << "]" #define el "\n" #define ld long double using namespace std; typedef long long ll; mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); long long randRange(long long l, long long r){ return uniform_int_distribution<long long>(l,r)(rng); } const int N = 2e5 + 5; long double cost(pair<ld, ld> last, ld x) { return (x - last.first) * (x - last.first) / (4 * last.second); } int n; ld ans[N]; void solve() { cin >> n; stack < pair<ld, ld> > st; for(int i = 1; i <= n; ++i) { ld x, r; cin >> x >> r; ld curR = r; while(st.size() > 0) { curR = min(curR, cost(st.top(), x)); if (curR >= st.top().second) { st.pop(); continue; } else break; } st.push({x, curR}); ans[i] = curR; } for(int i = 1; i <= n; ++i) cout << fixed << setprecision(3) << ans[i] << " "; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); #define task "bongbong" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } solve(); return 0; } /* */

Compilation message (stderr)

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