이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//dung stack de tim voi tat ca cac phan tu trong mang:
//phan tu gan nhat ve phia ben trai nho hon a[i]/lon hon a[i];
//stack chi tim duoc gan nhat
//tinh chat monotone:
//gia su khi them vao phan tu a[i] ta pop stack den phan tu a[j] thi cac phan tu a[t] sao cho j<t<i la mot day don dieu (MONOTONE)
//do ta pop tu a[i] den a[j] va pop het cac phan tu a[t] suy ra cac phan tu a[t] phai cung thoa man mot tinh chat nao neu khong thi khi them vao mot phan tu trong doan a[t] thi ta buoc phai pop mot so phan tu khac do mau thuan ve tinh chat
#include <bits/stdc++.h>
using namespace std;
stack<pair<long double, long double>>potential;
long double process(long double x, long double r){
while (!potential.empty()){
r=min(r, ((x-potential.top().first)*(x-potential.top().first))/(4*potential.top().second));
if (r>potential.top().second) potential.pop();
else break;
}
potential.push({x, r});
return r;
}
int n;
long double x[300005];
long double r[300005];
int main(){
cin>>n;
for (int i=1;i <=n; i++){
cin>>x[i]>>r[i];
}
for (int i=1;i <=n; i++){
cout<<fixed<<setprecision(3)<<process(x[i], r[i])<<'\n';
}
}
# | 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... |