QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#851852 | #9540. Double 11 | 11d10xy | WA | 122ms | 11084kb | C++14 | 1.3kb | 2025-01-11 08:04:50 | 2025-01-11 08:04:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using f128=long double;
int n,m,a[200010];
f128 pres[200010];
struct N_{
f128 v;int c;
N_ operator+(const N_&o)const{
return{v+o.v,c+o.c};
}
bool operator<(const N_&o)const{
return v<o.v;
}
}f[200010];
namespace ds{
int t[200010<<2];
N_ eval(int i,int k){
return k<=i?N_{(f128)1e18,0}:f[i]+N_{sqrt((k-i)*(pres[k]-pres[i])),0};
}
void insert(int u,int l,int r,int x){
if(t[u]==-1){t[u]=x;return;}
if(l==r)return;
int mid=l+r>>1;
if(eval(x,mid)<eval(t[u],mid))swap(t[u],x);
if(x<t[u])insert(u<<1,l,mid,x);
else insert(u<<1|1,mid+1,r,x);
}
N_ qry(int u,int l,int r,int p){
if(l==r)return eval(t[u],p);
int mid=l+r>>1;
return min(eval(t[u],p),p<=mid?qry(u<<1,l,mid,p):qry(u<<1|1,mid+1,r,p));
}
N_ work(f128 w){
memset(t,-1,sizeof(t));
t[1]=0;
for(int i=1;i<=n;i++){
f[i]=qry(1,1,n,i)+N_{-w,1},insert(1,1,n,i);
}
return f[n];
}
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
sort(a+1,a+n+1);
for(int i=1;i<=n;i++)pres[i]=pres[i-1]+a[i];
f128 l=-1e10,r=0;
for(int t=200;t--;){
f128 mid=(l+r)/2;
if(ds::work(mid).c<m)l=mid;
else r=mid;
}
printf("%.20Lf",ds::work(l).v+l*m);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 26ms
memory: 7552kb
input:
4 2 1 2 3 4
output:
6.19114712955711948405
result:
ok found '6.191147130', expected '6.191147130', error '0.000000000'
Test #2:
score: 0
Accepted
time: 27ms
memory: 10772kb
input:
10 3 1 2 3 4 5 6 7 8 9 10
output:
22.59162536651412858842
result:
ok found '22.591625367', expected '22.591625367', error '0.000000000'
Test #3:
score: 0
Accepted
time: 26ms
memory: 7392kb
input:
1 1 1
output:
1.00000000000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 22ms
memory: 11084kb
input:
1 1 100000
output:
316.22776601649820804596
result:
ok found '316.227766016', expected '316.227766017', error '0.000000000'
Test #5:
score: 0
Accepted
time: 22ms
memory: 7192kb
input:
7 1 10 47 53 9 83 33 15
output:
41.83300132676959037781
result:
ok found '41.833001327', expected '41.833001327', error '0.000000000'
Test #6:
score: 0
Accepted
time: 26ms
memory: 10304kb
input:
8 5 138 1702 119 1931 418 1170 840 1794
output:
233.90165455194358383462
result:
ok found '233.901654552', expected '233.901654552', error '0.000000000'
Test #7:
score: 0
Accepted
time: 29ms
memory: 10652kb
input:
58 1 888 251 792 847 685 3 182 461 102 348 555 956 771 901 712 878 580 631 342 333 285 899 525 725 537 718 929 653 84 788 104 355 624 803 253 853 201 995 536 184 65 205 540 652 549 777 248 405 677 950 431 580 600 846 328 429 134 983
output:
1355.26528768334537744522
result:
ok found '1355.265287683', expected '1355.265287684', error '0.000000000'
Test #8:
score: 0
Accepted
time: 29ms
memory: 10804kb
input:
88 30 67117 31903 93080 85196 16438 97116 11907 72959 83651 41273 52873 81892 81468 51323 99992 58869 54258 7183 87358 90990 80596 41252 90769 82705 61434 8524 13575 10787 53950 96768 12062 34637 27806 70937 69653 28380 90236 3352 27537 3873 91006 89790 25369 91825 82734 5588 4539 74118 47098 84741 ...
output:
18791.47535409410011197906
result:
ok found '18791.475354094', expected '18791.475354094', error '0.000000000'
Test #9:
score: -100
Wrong Answer
time: 122ms
memory: 7740kb
input:
987 59 5209 1618 7129 7700 893 6647 8231 3314 9844 1347 6789 2711 3968 7416 5864 9190 9564 8874 7357 2087 530 8754 7935 6772 3475 8206 2898 2717 9252 8686 6604 5188 7451 9977 9366 7618 6294 6454 3919 3232 8164 8403 8617 2191 5257 626 8554 1952 1727 4759 205 9453 3312 9387 4798 7774 7005 8892 3570 50...
output:
66075.50924497750034447563
result:
wrong answer 1st numbers differ - expected: '66075.5085871', found: '66075.5092450', error = '0.0000000'