Submission #724605

# Submission time Handle Problem Language Result Execution time Memory
724605 2023-04-15T16:07:57 Z Szil Balloons (CEOI11_bal) C++14
100 / 100
261 ms 5660 KB
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;

struct Circle {
    ld x, r;
};

ld inter(ld x0, ld x1, ld r) {
    return ((x0-x1)*(x0-x1))/(4*r);
}

void solve() {
    int n; cin >> n;
    vector<Circle> circles;
    while (n--) {
        ld x, lim; cin >> x >> lim;
        int i;
        for (i = circles.size() - 1; i >= 0; i--) {
            Circle &c = circles[i];
            lim = min(lim, inter(x, c.x, c.r));
            if (lim < c.r) {
                break;
            }
        }
        while (circles.size() > i + 1)
            circles.pop_back();
        circles.push_back({x, lim});
        cout << fixed << setprecision(3) << lim << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Compilation message

bal.cpp: In function 'void solve()':
bal.cpp:28:31: warning: comparison of integer expressions of different signedness: 'std::vector<Circle>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |         while (circles.size() > i + 1)
      |                ~~~~~~~~~~~~~~~^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 21 ms 724 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 58 ms 1960 KB 50000 numbers
2 Correct 50 ms 1612 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 113 ms 3012 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 132 ms 3404 KB 115362 numbers
2 Correct 127 ms 3468 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 187 ms 4284 KB 154271 numbers
2 Correct 221 ms 5660 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 261 ms 4736 KB 200000 numbers
2 Correct 210 ms 5520 KB 199945 numbers