Submission #754415

#TimeUsernameProblemLanguageResultExecution timeMemory
754415PanosPaskBalloons (CEOI11_bal)C++14
100 / 100
127 ms10108 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; radius[i] = maxradius[i]; while (!active_circles.empty()) { radius[i] = min(radius[i], allowed_radius(active_circles.back(), i)); if (radius[i] >= radius[active_circles.back()]) active_circles.pop_back(); else break; } active_circles.push_back(i); printf("%.3Lf\n", radius[i]); } return 0; }

Compilation message (stderr)

bal.cpp: In function 'int main()':
bal.cpp:37:14: warning: unused variable 'foundbreak' [-Wunused-variable]
   37 |         bool foundbreak = false;
      |              ^~~~~~~~~~
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...