Submission #842504

#TimeUsernameProblemLanguageResultExecution timeMemory
842504NoLoveBalloons (CEOI11_bal)C++14
100 / 100
699 ms6740 KiB
/** * author : Lăng Trọng Đạt * created: 2023-09-02 **/ #include <bits/stdc++.h> using namespace std; #define int int64_t const int MAXN = 2e5 + 5; int x[MAXN], r[MAXN];// f[i]: final radius of balloon i double f[MAXN]; int n; int32_t main() { cin.tie(0)->sync_with_stdio(0); std::cin >> n; for (int i = 1; i <= n; i++) { std::cin >> x[i] >> r[i]; } vector<int> s; // index of previous inflated balloon need to check, it will be decresing radius from top for (int b = 1; b <= n; b++) { f[b] = r[b]; while (!s.empty() && f[b] >= f[s.back()]) { int a = s.back(); f[b] = min(f[b], (x[b] - x[a]) * (x[b] - x[a]) / (4 * f[a])); if (f[b] >= f[s.back()]) s.pop_back(); } for (int a : s) { f[b] = min(f[b], (x[b] - x[a]) * (x[b] - x[a]) / (4 * f[a])); } s.push_back(b); cout << fixed << setprecision(4) << f[b] << "\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...