Submission #757510

# Submission time Handle Problem Language Result Execution time Memory
757510 2023-06-13T09:22:18 Z taitruong270 Balloons (CEOI11_bal) C++17
80 / 100
169 ms 10364 KB
/*==============================================================================================================
         __                    __                                             _____     ______    _______
        |  |                  |  |                                           /  __ \   / _____|  / ______|     
      __|  |__              __|  |__                                         |_|  | |  | |       | |  
     |__|   __|            |__|   __|                                             | |  | |____   | |_____ 
        |  |    _____   _     |  |    ____  __  __  ____    _____    _____       / /   \ ___  \  |  ___  \
        |  |   /  _  \ | |    |  |   /  _/ | | | | /  _  \ /  __ \  /  _  \     / /         | |  | |   | |
        |  |_  | |_| | | |    |  |_  | |   | |_| | | |_| | | |  | | | |_| |    / /___   ____| |  | |___| |
        \____\ \____/| |_|    \____\ |_|   \_____/ \_____/ |_|  |_| \____ |   |______| |______/  \_______/
                                                                        | |
                                                                      __/ |
                                                                     |___/  
                                        Pratice, practice, and practice
I hated every minute of training, but I said, ‘Don’t quit. Suffer now and live the rest of your life as a champion.' - Mohamed Ali 
                              You may not be the best, but must be the most effort
                                          Noi dau + Suy ngam = Tien bo 
==============================================================================================================*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl '\n'
const ll mod = 1e9+7;
ll n;
ld x[200000], r[200000];

//pair<ll, ll>   (x, r)
ld calc(pair<ld, ld> a, pair<ld, ld> b)
{
    return ((a.first-b.first)*(a.first-b.first))/(4*a.second);
}

void solve()
{
    cin>>n;
    for (ll i=1; i<=n; i++) cin>>x[i]>>r[i];
    vector<pair<ld, ld>> st;
    for (ll i=1; i<=n; i++)
    {
        ld max_r=r[i];
        while (!st.empty())
        {
            auto last=st.back();        
            max_r=min(max_r, calc(last, {x[i], r[i]}));
            if (max_r>=last.second) st.pop_back();
            else break;
        }
        cout<<fixed<<setprecision(3)<<max_r<<endl;
        st.push_back({x[i], max_r});
    }
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    clock_t start = clock();
    solve();
    clock_t end = clock();
    cerr<<"Time: "<<fixed<<setprecision(10)<<double(end-start)/double(CLOCKS_PER_SEC)<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1124 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 52 ms 2768 KB 50000 numbers
2 Correct 56 ms 3284 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 111 ms 4640 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 133 ms 5356 KB 115362 numbers
2 Correct 132 ms 7160 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 169 ms 6848 KB 154271 numbers
2 Incorrect 108 ms 10364 KB Unexpected end of file - double expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 6604 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -