Submission #1059696

# Submission time Handle Problem Language Result Execution time Memory
1059696 2024-08-15T07:13:55 Z Mazhavil Balloons (CEOI11_bal) C++17
100 / 100
168 ms 9812 KB
#include<bits/stdc++.h>
using namespace std;

void solve(){
   int n;cin>>n;
   vector<int>x(n), limit(n);
   for(int i=0;i<n;i++)cin>>x[i]>>limit[i];

   vector<double>radius(n);
   stack<int>st;

   for(int i=0;i<n;i++){
    double val_i = 1.0*limit[i];

    while(!st.empty()){ 
        // just touching the balloon;
        double curr = 1.0*(x[i]-x[st.top()])*(x[i]-x[st.top()])/(4.0*radius[st.top()]);

        if(curr < val_i){            
            val_i = curr;            
        }

        if(val_i >= radius[st.top()]){
              st.pop();  
        }else{
            break;
        }
    }

    st.push(i);
    radius[i]=val_i;
   }

   for(int i=0;i<n;i++)cout<<fixed<<setprecision(9)<<radius[i]<<" ";
   cout<<endl;
}

int main(){
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 344 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1116 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 42 ms 2472 KB 50000 numbers
2 Correct 40 ms 2640 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 84 ms 4800 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 104 ms 5456 KB 115362 numbers
2 Correct 97 ms 6004 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 132 ms 7344 KB 154271 numbers
2 Correct 161 ms 9812 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 168 ms 9044 KB 200000 numbers
2 Correct 161 ms 9812 KB 199945 numbers