Submission #848702

# Submission time Handle Problem Language Result Execution time Memory
848702 2023-09-13T10:02:52 Z Essa2006 Balloons (CEOI11_bal) C++14
100 / 100
149 ms 7808 KB
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define ll long long
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    vector<int>A(n);
    vector<double>Ans(n);
    stack<array<double, 2> >stk;
    for(int i=0;i<n;i++){
        double x, r;
        cin>>x>>r;
        A[i]=(int)x;
        while(!stk.empty()){
            double x2=stk.top()[0], y2=stk.top()[1];
            r=min(r, (x2-x)*(x2-x)/(4*y2));
            if(r>=y2)
                stk.pop();
            else break;
        
        }
        array<double, 2>a={x, r};
        stk.push(a);
        Ans[i]=r;
    }
    cout<<fixed<<setprecision(3);
    for(int i=0;i<n;i++){
        cout<<Ans[i]<<endl;
    }
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 544 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1112 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2148 KB 50000 numbers
2 Correct 35 ms 1368 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 82 ms 3920 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 97 ms 4688 KB 115362 numbers
2 Correct 85 ms 4944 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 120 ms 5868 KB 154271 numbers
2 Correct 142 ms 7808 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 148 ms 6992 KB 200000 numbers
2 Correct 149 ms 7760 KB 199945 numbers