QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#875520 | #9540. Double 11 | yuanruiqi | WA | 1ms | 8288kb | C++26 | 1.4kb | 2025-01-29 22:03:31 | 2025-01-29 22:03:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using ld = long double;
constexpr int maxn = 200000 + 10;
i64 a[maxn];
ld f[maxn];
int g[maxn];
ld get(int l, int r)
{
return f[l] + sqrtl((r - l) * (a[r] - a[l]));
}
int s[maxn], p[maxn];
int n, m;
ld calc(int x, int y)
{
int l = y, r = n;
while (l < r)
{
int m = (l + r + 1) >> 1;
if (get(x, m) <= get(y, m)) l = m;
else r = m - 1;
}
return r;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i=1;i<=n;++i) cin >> a[i];
sort(a + 1, a + n + 1);
for (int i=1;i<=n;++i) a[i] += a[i - 1];
ld L = -1e15, R = 1e15;
int c = 100;
while (c--)
{
ld M = (L + R) / 2;
f[0] = 0;
int l = 0, r = 0;
for (int i=1;i<=n;++i)
{
while (l < r && p[l] < i) ++l;
f[i] = get(s[l], i) + M;
g[i] = g[s[l]] + 1;
while (l < r)
{
ld x = calc(s[r], i);
if (x <= p[r - 1]) --r;
else break;
}
p[r] = calc(s[r], i);
s[++r] = i;
}
if (g[n] > m) L = M;
else R = M;
if (!c) return cout << fixed << setprecision(15) << f[n] - M * g[n] << '\n', 0;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 8136kb
input:
4 2 1 2 3 4
output:
6.191147129557119
result:
ok found '6.191147130', expected '6.191147130', error '0.000000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 8288kb
input:
10 3 1 2 3 4 5 6 7 8 9 10
output:
22.591625366514129
result:
ok found '22.591625367', expected '22.591625367', error '0.000000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 8160kb
input:
1 1 1
output:
1.000000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 8284kb
input:
1 1 100000
output:
316.227783203125000
result:
wrong answer 1st numbers differ - expected: '316.2277660', found: '316.2277832', error = '0.0000001'