This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)) return true; //kesişiyorlar
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |