Submission #872458

# Submission time Handle Problem Language Result Execution time Memory
872458 2023-11-13T06:56:14 Z sleepntsheep Balloons (CEOI11_bal) C++17
50 / 100
2000 ms 8016 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];

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

    deque<int> q;
    q.push_back(0);

    for (int st = 0, i = 1; i < n; ++i)
    {
        for (auto it = q.rbegin(); it != q.rend(); ++it)
        {
            int j = *it;
            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);
        }

        while (q.size() && ::r[q.back()] <= ::r[i]) q.pop_back();
        q.push_back(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:37:14: warning: unused variable 'st' [-Wunused-variable]
   37 |     for (int st = 0, i = 1; i < n; ++i)
      |              ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 360 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 76 ms 2900 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2045 ms 2924 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2020 ms 3108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2029 ms 3176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2050 ms 3668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1927 ms 5904 KB 200000 numbers
2 Execution timed out 2051 ms 8016 KB Time limit exceeded
3 Halted 0 ms 0 KB -