Submission #988335

# Submission time Handle Problem Language Result Execution time Memory
988335 2024-05-24T14:11:55 Z hegoplay Balloons (CEOI11_bal) C++14
20 / 100
141 ms 15216 KB
/*
                                                                                                        -
                                                             +=
                                                           @@@@@%
                                                         +@@@@@@+
                                                      %@@@@@#%
                                                     @@@@@@@@=:
                       +******************         =@@@@@@@@@%         =***********#*******+
                    %@@@@@@@@@@@@@@@@@@@@=         @@@@@@@@@@%      #@@@@@@@@@@@@@@@@@@@@@@
                  +@@@@@@@@@@@@@@@@@@@@@+        +@@#@@@@@@@@%     @@@@@@@@@@@@@@@@@@@@@@@=
                 +@@@@%                         *@@%@@@@@@@@@=    %@@@%
                 @@@@@#                        *@@@@@@@@@@@@#    #@@@@@
                %@@@@%                        +@@@@@@@@@@@@%     @@@@@@@@@@@@@@@@@@@@%
               #@@@@@                        =#+@@@@@@@@#@%      =@@@@@@@@@@@@@@@@@@@@*
              +@@@@@+                         #@@@@@@%                          =@@@@@=
             =@@@@@*                        #@@@@@@#                            @@@@@*
             #@@@@@@@@@@@@@@@@@@@@@       +@@@@@@#           *@@@@@@@@@@@@@@@@@@@@@@#
             +@@@@@@@@@@@@@@@@@@@@=      %@@@@@%            +@@@@@@@@@@@@@@@@@@@@@@+
               +*#************##*      =@@@@@#+             ###**##**#*******##*+
                                      =@@@@@@%
                                        +**  =+=
                                    Michael Jackson peeks

    "Nothing is hard to understand, you just didn't get it."
    @author: MahK17
*/

#include <bits/stdc++.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <sstream>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define inf 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(), (x).end()
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define sz(x) (int)(x).size()
#define el "\n"
typedef long long ll;
typedef long double ld;
#define int long long

using namespace __gnu_pbds;
using namespace std;

#define indexed_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

void setIO(string name = "")
{
    if (sz(name))
    {
        freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

ld find(ld lb, ld x1, ld x2)
{
    // binary search 4*lb*x = (x1-x2)**2
    return (x1 - x2) * (x1 - x2) / (4 * lb);
}

void solve()
{
    int n;
    cin >> n;
    vector<pair<ld, ld>> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].first >> a[i].second;
    }
    stack<pair<ld, ld>> s;
    for (int i = 0; i < n; i++)
    {
        ld curSize = 1e10;
        ld firstLast = -1;
        ld secondLast = -1;
        while (!s.empty())
        {
            ld x1 = s.top().first;
            ld x2 = a[i].first;
            ld lb = s.top().second;
            ld x = find(lb, x1, x2);
            if (x < curSize)
            {
                firstLast = s.top().first;
                secondLast = s.top().second;

                s.pop();
                curSize = x;
            }
            else
                break;
        }
        if (firstLast != -1)
            s.push({firstLast, secondLast});
        s.push({a[i].first, min(curSize, a[i].second)});
        printf("%.3Lf\n", min(curSize, a[i].second));
    }
}

signed main()
{

    ios ::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

Compilation message

bal.cpp: In function 'void setIO(std::string)':
bal.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 17th numbers differ - expected: '213.0000000000', found: '234.0000000000', error = '21.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB 504th numbers differ - expected: '160.9360000000', found: '163.0000000000', error = '2.0640000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2120 KB 653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 4052 KB 13980th numbers differ - expected: '15342.0210000000', found: '15351.0000000000', error = '8.9790000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 79 ms 8616 KB 7247th numbers differ - expected: '7934.1500000000', found: '7939.0000000000', error = '4.8500000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 9728 KB 4681st numbers differ - expected: '5052.5810000000', found: '5081.0000000000', error = '28.4190000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 12832 KB 1734th numbers differ - expected: '1856.0220000000', found: '1865.0000000000', error = '8.9780000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 141 ms 15216 KB 2735th numbers differ - expected: '1883.4630000000', found: '1899.0000000000', error = '15.5370000000'
2 Halted 0 ms 0 KB -