Submission #919682

# Submission time Handle Problem Language Result Execution time Memory
919682 2024-02-01T12:13:37 Z buzdi Balloons (CEOI11_bal) C++14
20 / 100
161 ms 10192 KB
//#include <fstream>
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#include <vector>
#include <cassert>
#include <map>
#include <iomanip>
#define ll long long
#include <cmath>

using namespace std;

const int NMAX = 2e5;

struct Point
{
    long double x, y;
    void Read()
    {
        cin >> x >> y;
    }
};

int n;
Point a[NMAX + 1];
long double answer[NMAX + 1];
Point st[NMAX + 1];
int indst;

long double Square(long double x)
{
    return x * x;
}

long double Distance(Point p1, Point p2)
{
    return sqrt(Square(p1.x - p2.x) - Square(p1.y - p2.y));
}

long double Radius(Point p1, Point p2)
{
    return Square(p2.x - p1.x) / (4.0 * p1.y);
}

bool Okay(Point p1, Point p2)
{
    return p1.y + p2.y <= Distance(p1, p2);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++)
        a[i].Read();

    for (int i = 1; i <= n; i++)
    {
        while (indst > 1 && !Okay({ a[i].x, Radius(st[indst], a[i]) }, st[indst - 1]))
            indst--;

        if (indst > 0 && Radius(st[indst], a[i]) <= a[i].y)
            a[i].y = Radius(st[indst], a[i]);

        while (indst > 0 && a[i].y >= st[indst].y)
            indst--;
        st[++indst] = a[i];
    }

    for (int i = 1; i <= n; i++)
        cout << fixed << setprecision(3) << a[i].y << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2392 KB 13th numbers differ - expected: '2.3960000000', found: '6.2550000000', error = '3.8590000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2592 KB 114th numbers differ - expected: '39.0180000000', found: '56.0000000000', error = '16.9820000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 2640 KB 196th numbers differ - expected: '100.7250000000', found: '111.0000000000', error = '10.2750000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 7164 KB 14044th numbers differ - expected: '0.4860000000', found: '0.5200000000', error = '0.0340000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 9808 KB 7309th numbers differ - expected: '0.3220000000', found: '0.7860000000', error = '0.4640000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 9676 KB 4790th numbers differ - expected: '0.2950000000', found: '0.8600000000', error = '0.5650000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 130 ms 10192 KB 1732nd numbers differ - expected: '2.0480000000', found: '2.8120000000', error = '0.7640000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 161 ms 9296 KB 2716th numbers differ - expected: '22.1690000000', found: '43.0000000000', error = '20.8310000000'
2 Halted 0 ms 0 KB -