QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#842130#9966. High Jumpucup-team6274#WA 1ms7980kbC++142.6kb2025-01-04 10:25:192025-01-04 10:25:26

Judging History

你现在查看的是最新测评结果

  • [2025-01-04 10:25:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7980kb
  • [2025-01-04 10:25:19]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
bool Mbg;
using namespace std;
#define vec vector
#define pb push_back
#define eb emplace_back
#define siz(vec) ((int)(vec).size())
#define all(vec) (vec).begin(),(vec).end()
template<class T>
void operator +=(vec<T> &a,T b){a.push_back(b);}
template<class T>
void operator --(vec<T> &a){a.pop_back();}
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define exc(exp) if(exp)continue;
#define stop(exp) if(exp)break;
#define ret(exp) if(exp)return;
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define debl(var) cerr<<#var<<'='<<(var)<<";\n"
#define ins insert
#define era erase
#define lb lower_bound
#define ub upper_bound
#define int long long
#define inf (long long)(1e18)
template<class T>
bool Min(T &x,T y){return x>y?x=y,1:0;}
template<class T>
bool Max(T &x,T y){return x<y?x=y,1:0;}
const int mod=1e9+7;
void Add(int &x,int y){x=x+y<mod?x+y:x+y-mod;}
void Dec(int &x,int y){x=x>=y?x-y:x-y+mod;}
int fpm(int x,int y){
    int ans=1;for(;y;y>>=1,(x*=x)%=mod)if(y&1)(ans*=x)%=mod;return ans;
}
#define ld long double

int n;
ld p[500010],va[500010];

struct line{
    ld k,b;
    ld f(int x){
        return k*x+b;
    }
}w[2000010];
#define ls (u<<1)
#define rs (u<<1|1)
void mk(int u,int l,int r,line tag){
    if(l>r)return;
    int mid=(l+r)>>1;
    if(w[u].f(mid)<tag.f(mid))swap(w[u],tag);

    if(tag.f(l)>w[u].f(l)){
        mk(ls,l,mid,tag);
    }else{
        mk(rs,mid+1,r,tag);
    }
}
ld qry(int u,int l,int r,int x){
    if(l==r)return w[u].f(x);
    int mid=(l+r)>>1;
    if(x<=mid){
        return max(w[u].f(x),qry(ls,l,mid,x));
    }else{
        return max(w[u].f(x),qry(rs,mid+1,r,x));
    }
}
void work(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>p[i];  
    }
    for(int i=n,j=n+1;~i;i--){
        // va[i]=p[j]*(j-i+va[j]);
        // while(j>i+1&&p[j-1]*(j-1-i+va[j-1])>=va[i]-1e-9){
            // j--;
            // Max(va[i],p[j]*(j-i+va[j]));
        // }
        // for(int k=max(j-200,i+1);k<=min(j+200,n+1);k++){
            // Max(va[i],p[k]*(k-i+va[k]));
        // }
        va[i]=qry(1,1,n,i);
        mk(1,1,n,{-p[i],p[i]*(i+va[i])});
    }
    cout<<fixed<<setprecision(12)<<va[0]<<'\n';
}
bool Med;
signed main(){
    ios::sync_with_stdio(0),
    cin.tie(0),cout.tie(0);
    int T=1;while(T--)work();
    // cerr<<"Time: "<<clock()<<" ms;\n";
    // cerr<<"Memory: "<<abs(&Med-&Mbg)/1024.0/1024.0<<" MiB.\n";
}
/*
- CONTINUE, NON-STOPPING, FOR THE FAITH
- START TYPING IF YOU DON'T KNOW WHAT TO DO
- STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
*/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 7952kb

input:

5
0.9 0.85 0.6 0.456000 0.000000017

output:

2.475200006589

result:

ok found '2.4752000', expected '2.4752000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 7976kb

input:

1
0.000000001

output:

0.000000000000

result:

ok found '0.0000000', expected '0.0000000', error '0.0000000'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 7980kb

input:

2
0.828496829 0.645649353

output:

1.291298706000

result:

wrong answer 1st numbers differ - expected: '1.3634153', found: '1.2912987', error = '0.0528941'