Submission #680245

#TimeUsernameProblemLanguageResultExecution timeMemory
680245peijarBalloons (CEOI11_bal)C++17
60 / 100
2084 ms3412 KiB
#include <bits/stdc++.h> #define int long long using namespace std; namespace std { template <typename T> ostream &operator<<(ostream &out, const vector<T> &vec) { out << "["; for (int i = 0; i < (int)vec.size(); ++i) { out << vec[i]; if (i + 1 < (int)vec.size()) out << ", "; } return out << "]"; } } // namespace std void dbg_out() { cout << endl; } template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); } #ifdef DEBUG #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) #endif double sq(int x) { return x * x; } struct Polynome { double a, b, c; bool operator<(Polynome other) const { return tuple(a, b, c) > tuple(other.a, other.b, other.c); }; double eval(double x) const { return a * x * x + b * x + c; } }; signed main(void) { ios_base::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<int> x(N); vector<double> r(N); for (int i = 0; i < N; ++i) { cin >> x[i] >> r[i]; } priority_queue<Polynome> polynomes; for (int i = 0; i < N; ++i) { while (polynomes.size() > 1) { auto &pol = polynomes.top(); polynomes.pop(); if (pol.eval(x[i]) <= polynomes.top().eval(x[i])) continue; polynomes.push(pol); break; } if (!polynomes.empty()) { r[i] = min(r[i], polynomes.top().eval(x[i])); } polynomes.push({1 / (4 * r[i]), x[i] / (2 * r[i]), sq(x[i]) / (4 * r[i])}); } for (int i = 1; i < N; ++i) { for (int j = 0; j < i; ++j) r[i] = min(r[i], sq(x[i] - x[j]) / (4 * r[j])); } for (int i = 0; i < N; ++i) { cout << setprecision(15) << fixed << r[i] << '\n'; } }
#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...