Submission #1114258

# Submission time Handle Problem Language Result Execution time Memory
1114258 2024-11-18T13:10:07 Z asli_bg Balloons (CEOI11_bal) C++11
100 / 100
472 ms 8776 KB
#include <bits/stdc++.h>
using namespace std;

#define int double

#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sp <<' '<<

#define FOR(i,a) for(int i=0;i<(a);i++)
#define FORE(i,a,b) for(int i=(a);i<(b);i++)

#define cont(a) for(auto el:a) cout<<el<<' '; cout<<endl;
#define contp(a) for(auto el:a) cout<<el.fi<<'-'<<el.se<<' ';cout<<endl;

#define DEBUG(x) cout<<#x sp ":" sp x<<endl;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef long long ll;

#define endl '\n'
#define mid (l+r)/2

const int MAXN=2e5+5;

int n;

bool check(int a,int b,int c){
    //c max possible hipotenus
    int hipo=pow(a,2)+pow(b,2);
    if(c>=sqrt(hipo)){
        //kesişiyorlar
        return true;
    }
    return false;
}

int findr(int mxr,int prevr,int xfark){ //kesiştikleri son noktayı bul  
    int l=0;
    int r=mxr;

    FOR(i,50){
        if(check(abs(mid-prevr),xfark,mid+prevr)) r=mid;
        else l=mid;
    }

    return l;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cout<<fixed<<setprecision(3);

    cin>>n;
    vi cev(n+1,0);

    stack<pii> s; //{x eksenini nereden keser, radyan ne kadar}

    FORE(i,1,n+1){

        int x,r;
        cin>>x>>r;

        pii el;
        while(!s.empty() and r>el.se){
            el=s.top();
            int deg=findr(r,el.se,x-el.fi);

            r=deg;

            if(r>el.se) s.pop();
        }

        s.push({x,r}); 

        cout<<r<<endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 47 ms 992 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 117 ms 1788 KB 50000 numbers
2 Correct 123 ms 2120 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 236 ms 3400 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 271 ms 3912 KB 115362 numbers
2 Correct 277 ms 4408 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 382 ms 5132 KB 154271 numbers
2 Correct 460 ms 8776 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 459 ms 6132 KB 200000 numbers
2 Correct 472 ms 6984 KB 199945 numbers