Submission #988271

# Submission time Handle Problem Language Result Execution time Memory
988271 2024-05-24T11:57:25 Z hegoplay Balloons (CEOI11_bal) C++17
0 / 100
34 ms 65536 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<int, int>> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].first >> a[i].second;
    }
    stack<pair<int, int>> s;
    for (int i = 0; i < n; i++)
    {
        ld curSize = a[i].second;

        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)
            {
                s.pop();
                curSize = x;
            }
            else
                break;
        }
        s.push({a[i].first, curSize});
        printf("%.3Lf\n", curSize);
    }
}

signed main()
{
#ifndef ONLINE_JUDGE
    std::freopen("bal.txt", "r", stdin);
    std::freopen("bal.txt", "w", stdout);
    // setIO("snakes");
#endif

    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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp: In function 'int main()':
bal.cpp:113:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  113 |     std::freopen("bal.txt", "r", stdin);
      |     ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:114:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  114 |     std::freopen("bal.txt", "w", stdout);
      |     ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -