Submission #754403

#TimeUsernameProblemLanguageResultExecution timeMemory
754403PanosPaskBalloons (CEOI11_bal)C++14
20 / 100
139 ms10056 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; int n; vector<int> active_circles; vector<long double> radius; vector<int> maxradius; vector<int> position; long double find_r2(int x1, long double r1, int x2) { return ((ll)(x1 - x2) * (x1 - x2)) / (4 * r1); } long double allowed_radius(int i, int j) { return find_r2(position[i], radius[i], position[j]); } int main(void) { scanf("%d", &n); position.resize(n); maxradius.resize(n); radius.resize(n); for (int i = 0; i < n; i++) { scanf("%d %d", &position[i], &maxradius[i]); } for (int i = 0; i < n; i++) { bool foundbreak = false; while (active_circles.size() >= 2 && !foundbreak) { int mid = active_circles.back(); int prv = active_circles[active_circles.size() - 2]; if (allowed_radius(prv, i) <= allowed_radius(mid, i)) { active_circles.pop_back(); } else foundbreak = true; } radius[i] = maxradius[i]; if (!active_circles.empty()) radius[i] = min(radius[i], allowed_radius(active_circles.back(), i)); active_circles.pb(i); printf("%.3Lf\n", radius[i]); } return 0; }

Compilation message (stderr)

bal.cpp: In function 'int main()':
bal.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bal.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%d %d", &position[i], &maxradius[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...