Submission #488462

# Submission time Handle Problem Language Result Execution time Memory
488462 2021-11-19T07:12:01 Z s_jaskaran_s Balloons (CEOI11_bal) C++17
100 / 100
507 ms 8348 KB
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ld a[n];
    ld r[n];
    vector<pair<ld,ld>> s;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ld l;
        cin>>l;
        if(i==0){
            r[i]=l;
        }
        else{
            r[i]=l;
            while(s.size()){
                r[i]=min(r[i],((a[i]-s.back().first)*(a[i]-s.back().first))/(4*s.back().second));
                if(s.back().second<=r[i]){
                    s.pop_back();
                }
                else{
                    break;
                }
            }
        }
        s.push_back({a[i],r[i]});
        cout<<fixed<<setprecision(3)<<r[i]<<endl;
    }
    
}    
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 6 ms 440 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 45 ms 1152 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 121 ms 2800 KB 50000 numbers
2 Correct 120 ms 2476 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 226 ms 4688 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 282 ms 5520 KB 115362 numbers
2 Correct 266 ms 5132 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 362 ms 6812 KB 154271 numbers
2 Correct 439 ms 8096 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 472 ms 8348 KB 200000 numbers
2 Correct 507 ms 8124 KB 199945 numbers