QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#843126 | #9966. High Jump | 玩原神的都进队了 (Junlin Ye, Ruichen Dai, Chenghan Li)# | WA | 1ms | 8100kb | C++14 | 978b | 2025-01-04 16:55:32 | 2025-01-04 16:55:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define MP make_pair
mt19937 rnd(time(0));
const int MAXN=5e5+5;
ld f[MAXN],a[MAXN];int n;
ld z(int j,int i){return a[j]*f[j]+(1-a[j])*i;}
struct info { int l,r,x; } g[MAXN];
int main(){
// freopen("Otomachi_Una.in","r",stdin);
// freopen("Otomachi_Una.out","w",stdout);
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
int tp=0,hd=1;
g[++tp]={1,n,n},f[n]=n;
for(int i=n-1;i>=0;--i) {
while(hd<tp&&i<g[hd].l) ++hd;
f[i]=z(g[hd].x,i);
if(!i) break;
while(tp&&z(g[tp].x,g[tp].r)<z(i,g[tp].r)) --tp;
if(!tp) g[++tp]={0,i-1,i};
else {
int l=g[tp].l,r=g[tp].r-1,k=g[tp].r;
while(l<=r) {
int mid=(l+r)>>1;
if(z(g[tp].x,mid)>z(i,mid)) k=mid,r=mid-1;
else l=mid+1;
}
g[tp].l=k;
if(k>1) g[++tp]={0,k-1,i};
}
}
cout<<fixed<<setprecision(20)<<f[0]<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7984kb
input:
5 0.9 0.85 0.6 0.456000 0.000000017
output:
2.47520000658920000009
result:
ok found '2.4752000', expected '2.4752000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 8100kb
input:
1 0.000000001
output:
0.00000000100000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 7984kb
input:
2 0.828496829 0.645649353
output:
1.29129870600000000002
result:
wrong answer 1st numbers differ - expected: '1.3634153', found: '1.2912987', error = '0.0528941'