#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
double dp[200100];
int cou[200100];
int N;
int f(double c)
{
int s = 1;
int i;
dp[0] = 0;
for (i = 1; i <= N; i++)
{
dp[i] = (double)s / i;
dp[i] += dp[i-s]-c;
while (s < i)
{
double newdp = (double)(s + 1) / i + dp[i - s - 1] - c;
if (newdp > dp[i])
{
dp[i] = newdp;
s++;
}
else
break;
}
cou[i] = cou[i - s] + 1;
}
return cou[N];
}
signed main()
{
int M;
cin >> N >> M;
double s = 0, e = 10;
int i;
for (i = 0; i < 60; i++)
{
if (s >= e)
break;
double m = (s + e) / 2;
if (f(m) > M)
s = m;
else
e = m;
}
printf("%.15f", dp[N]+M*s);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1740 KB |
Output is correct |
2 |
Correct |
41 ms |
1740 KB |
Output is correct |
3 |
Correct |
39 ms |
1612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1800 KB |
Output is correct |
2 |
Correct |
42 ms |
1740 KB |
Output is correct |
3 |
Correct |
44 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
1740 KB |
Output is correct |
2 |
Correct |
43 ms |
1844 KB |
Output is correct |
3 |
Correct |
43 ms |
1824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
1740 KB |
Output is correct |
2 |
Correct |
42 ms |
1740 KB |
Output is correct |
3 |
Correct |
40 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
1740 KB |
Output is correct |
2 |
Correct |
46 ms |
1740 KB |
Output is correct |
3 |
Correct |
41 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1844 KB |
Output is correct |
2 |
Correct |
42 ms |
1772 KB |
Output is correct |
3 |
Correct |
46 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1796 KB |
Output is correct |
2 |
Correct |
39 ms |
1708 KB |
Output is correct |
3 |
Correct |
43 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1740 KB |
Output is correct |
2 |
Correct |
43 ms |
1856 KB |
Output is correct |
3 |
Correct |
40 ms |
1612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1740 KB |
Output is correct |
2 |
Correct |
42 ms |
1800 KB |
Output is correct |
3 |
Correct |
43 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1824 KB |
Output is correct |
2 |
Correct |
42 ms |
1792 KB |
Output is correct |
3 |
Correct |
43 ms |
1816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1740 KB |
Output is correct |
2 |
Correct |
46 ms |
1740 KB |
Output is correct |
3 |
Correct |
44 ms |
1848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
1740 KB |
Output is correct |
2 |
Correct |
43 ms |
1740 KB |
Output is correct |
3 |
Correct |
44 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
1844 KB |
Output is correct |
2 |
Correct |
43 ms |
1740 KB |
Output is correct |
3 |
Correct |
43 ms |
1740 KB |
Output is correct |