Submission #717824

# Submission time Handle Problem Language Result Execution time Memory
717824 2023-04-02T15:39:56 Z adrilen Balloons (CEOI11_bal) C++17
100 / 100
275 ms 5880 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ld = long double;
typedef pair<ld, ld> pii;

ld dist(ld dx, ld r)
{
    return dx * dx / (4 * r);
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;

    cout << fixed << setprecision(5);
    
    stack<pii> s;

    ld x, r, l;
    while (n--)
    {
        cin >> x >> r;
        while (s.size()) {

            l = dist(s.top().first - x, s.top().second);

            l = min(l, r);

            if (l >= s.top().second) {
                s.pop();
                r = min(r, l);
            } else {
                r = l;
                break;
            }
        }
        s.push(pii(x, r));
        cout << r << "\n";
    }
}
# 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 23 ms 468 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 72 ms 1172 KB 50000 numbers
2 Correct 60 ms 1704 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 138 ms 1740 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 160 ms 1880 KB 115362 numbers
2 Correct 143 ms 3672 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 224 ms 2176 KB 154271 numbers
2 Correct 222 ms 5880 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 275 ms 2260 KB 200000 numbers
2 Correct 241 ms 5820 KB 199945 numbers