#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 |
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 |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
3 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 |
3 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 |
340 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 |
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 |
45 ms |
1740 KB |
Output is correct |
2 |
Correct |
42 ms |
1780 KB |
Output is correct |
3 |
Correct |
40 ms |
1716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1740 KB |
Output is correct |
2 |
Correct |
43 ms |
1740 KB |
Output is correct |
3 |
Correct |
42 ms |
1788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1740 KB |
Output is correct |
2 |
Correct |
47 ms |
1840 KB |
Output is correct |
3 |
Correct |
44 ms |
1836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
1800 KB |
Output is correct |
2 |
Correct |
42 ms |
1740 KB |
Output is correct |
3 |
Correct |
40 ms |
1760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1740 KB |
Output is correct |
2 |
Correct |
47 ms |
1740 KB |
Output is correct |
3 |
Correct |
42 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1740 KB |
Output is correct |
2 |
Correct |
41 ms |
1740 KB |
Output is correct |
3 |
Correct |
43 ms |
1756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1740 KB |
Output is correct |
2 |
Correct |
41 ms |
1612 KB |
Output is correct |
3 |
Correct |
40 ms |
1612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
1740 KB |
Output is correct |
2 |
Correct |
43 ms |
1740 KB |
Output is correct |
3 |
Correct |
41 ms |
1612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
1828 KB |
Output is correct |
2 |
Correct |
42 ms |
1740 KB |
Output is correct |
3 |
Correct |
43 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1740 KB |
Output is correct |
2 |
Correct |
43 ms |
1776 KB |
Output is correct |
3 |
Correct |
43 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
1740 KB |
Output is correct |
2 |
Correct |
44 ms |
1740 KB |
Output is correct |
3 |
Correct |
45 ms |
1840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1740 KB |
Output is correct |
2 |
Correct |
45 ms |
1740 KB |
Output is correct |
3 |
Correct |
43 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
1740 KB |
Output is correct |
2 |
Correct |
44 ms |
1740 KB |
Output is correct |
3 |
Correct |
46 ms |
1844 KB |
Output is correct |