QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#733898 | #9540. Double 11 | forget-star | WA | 1ms | 10196kb | C++20 | 1.2kb | 2024-11-10 21:53:38 | 2024-11-10 21:53:39 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define fr(i,a,b) for(int i(a),end##i(b);i<=end##i;i++)
#define fd(i,a,b) for(int i(a),end##i(b);i>=end##i;i--)
#define de fprintf(stderr,"on-%d\n",__LINE__)
using namespace std;
const int maxn=2e5+5;
int a[maxn];
int n,m;
double f[maxn];
int s[maxn];
int fa[maxn];
int find(int x){
if(fa[x]==x)return x;
return fa[x]=find(fa[x]);
}
double S[maxn];
double w(int x,int y){
return sqrt(1.*(s[y]-s[x])*(y-x));
}
struct node{
int x,l,r;
};
deque<node> Q;
int d[maxn];
int pre[maxn];
const double eps=1e-9;
int solve(double del){
fr(i,1,n){
f[i]=10000;
fr(j,0,i-1)if(f[i]>f[j]+w(j,i)+del){
f[i]=f[j]+w(j,i)+del;
pre[i]=j;
d[i]=d[j]+1;
}
}
return d[n];
}
signed main(){
#ifdef pig
freopen("pig.in","r",stdin);
freopen("bf.out","w",stdout);
#endif
cin>>n>>m;
fr(i,1,n)scanf("%lld",&a[i]);
sort(a+1,a+n+1);
fr(i,1,n)s[i]=s[i-1]+a[i];
double l=0,r=1e9;
while(r-l>eps){
double mid=(l+r)/2;
int t=solve(mid);
if(t==m){
printf("%.12lf\n",f[n]-mid*m);
return 0;
}
if(t<m)r=mid;
else l=mid;
}
printf("%.12lf\n",f[n]-l*m);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 10196kb
input:
4 2 1 2 3 4
output:
6.191147129557
result:
ok found '6.191147130', expected '6.191147130', error '0.000000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 7948kb
input:
10 3 1 2 3 4 5 6 7 8 9 10
output:
22.591625366514
result:
ok found '22.591625367', expected '22.591625367', error '0.000000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 7944kb
input:
1 1 1
output:
1.000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 1ms
memory: 8096kb
input:
1 1 100000
output:
316.227766016838
result:
ok found '316.227766017', expected '316.227766017', error '0.000000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 9956kb
input:
7 1 10 47 53 9 83 33 15
output:
41.833001326704
result:
ok found '41.833001327', expected '41.833001327', error '0.000000000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 10140kb
input:
8 5 138 1702 119 1931 418 1170 840 1794
output:
233.901654551944
result:
ok found '233.901654552', expected '233.901654552', error '0.000000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 7896kb
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.265287683560
result:
ok found '1355.265287684', expected '1355.265287684', error '0.000000000'
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 9992kb
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:
10000.000000000000
result:
wrong answer 1st numbers differ - expected: '18791.4753541', found: '10000.0000000', error = '0.4678438'