Submission #872463

# Submission time Handle Problem Language Result Execution time Memory
872463 2023-11-13T07:09:57 Z sleepntsheep Balloons (CEOI11_bal) C++17
10 / 100
143 ms 5952 KB
#include <iostream>
#include <iomanip> 
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>

using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
#define N 200005

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")

int n, x[N];
f80 r[N];

struct line
{
    f80 m, c;
    int i;
    f80 operator[](i64 x) { return m*x+c; }
    f80 intersectx(const line &l) { return f80(l.c - c) / (m - l.m); }
};


deque<line> lc;

void add(line k)
{
    while (lc.size())
    {
        if (lc.back().m >= k.m) lc.pop_back();
        else if (lc.size() > 1 && k.intersectx(lc.back()) <= k.intersectx(lc[lc.size()-2])) lc.pop_back();
        else break;
    }
    lc.push_back(k);
}

f80 qry(i64 x)
{
    u64 l = 1, r = lc.size(), z = 0;
    for (; l <= r;)
    {
        u64 m = (l+r)/2;
        if (lc[m].intersectx(lc[m-1]) >= x) z = m, r = m - 1;
        else l = m + 1;
    }
    return lc[z].i;
}

int main()
{
    ShinLena;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> x[i] >> r[i];

    add({-*r, 1L**r**r, 0});

    for (int st = 0, i = 1; i < n; ++i)
    {
        int j = qry(x[i]);
        f80 A = (1L * x[i] * x[i] + 1L * x[j] * x[j] - 2L * x[i] * x[j]) / (4L * r[j]);
        r[i] = min(r[i], A);

        add({-r[i], 1L*r[i]*r[i], i});
    }

    cout << fixed << setprecision(3);
    for (int i = 0; i < n; ++i)
        cout << r[i] << '\n';

    return 0;
}


Compilation message

bal.cpp: In function 'int main()':
bal.cpp:70:14: warning: unused variable 'st' [-Wunused-variable]
   70 |     for (int st = 0, i = 1; i < n; ++i)
      |              ^~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB 7th numbers differ - expected: '11.4400000000', found: '81.0000000000', error = '69.5600000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 3rd numbers differ - expected: '0.0420000000', found: '3.0000000000', error = '2.9580000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB 3rd numbers differ - expected: '121.0000000000', found: '123.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2908 KB 3rd numbers differ - expected: '211.0000000000', found: '213.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 3184 KB 5th numbers differ - expected: '15395.0000000000', found: '15396.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 3924 KB 3rd numbers differ - expected: '7936.0000000000', found: '10352.0000000000', error = '2416.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 4112 KB 5th numbers differ - expected: '5054.0000000000', found: '5055.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 4688 KB 3rd numbers differ - expected: '1872.0000000000', found: '1874.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 143 ms 5952 KB 3rd numbers differ - expected: '2960.0000000000', found: '2962.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -