#include<bits/stdc++.h>
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(15);
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
#define x first
#define y second
pair<double,double> cad[501];
double sol(ll l,ll n,ll m)
{
vector<vector<vector<double>>> dp(2,vector<vector<double>>(m+3,vector<double>(m+3,1e9)));
dp[0][1][1]=0;
double bs=1e9;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=l; j++)
{
for(int k=1; k<=m+1; k++)
{
double temp=1e9;
temp=min(temp,dp[0][j][k]);
temp=min(temp,dp[0][j][k-1]+cad[i].y/l);
if(cad[i].first!=-1&&j!=1)
temp=min(temp,dp[0][j-1][k-1]+cad[i].x/(j-1));
dp[1][j][k]=temp;
if(k==m+1&&j==l) bs=min(bs,dp[1][j][k]);
}
//cout<<"\n";
}
swap(dp[0],dp[1]);
//cout<<"\n\n";
}
return bs;
}
int main()
{
optimizar_io
ll n,m;
cin>>n>>m;
cad[0]={-1,-1};
for(int i=1; i<=n; i++)
cin>>cad[i].second>>cad[i].first;
sort(cad,cad+n+1);
double bs=1e9;
double lo = 0, hi = m+1;
for (int i = 0; i < 23; ++i) {
double delta = (hi-lo)/3.0;
double m1 = lo+delta;
double m2 = hi-delta;
double f1=sol(m1,n,m);
double f2=sol(m2,n,m);
bs=min(bs,f1);
bs=min(bs,f2);
(f1 > f2) ? lo = m1 : hi = m2;
}
cout<<bs;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
25 ms |
532 KB |
Output is correct |
6 |
Correct |
142 ms |
864 KB |
Output is correct |
7 |
Correct |
599 ms |
2136 KB |
Output is correct |
8 |
Correct |
1349 ms |
4012 KB |
Output is correct |
9 |
Correct |
2260 ms |
6772 KB |
Output is correct |
10 |
Correct |
1079 ms |
3440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
25 ms |
532 KB |
Output is correct |
6 |
Correct |
142 ms |
864 KB |
Output is correct |
7 |
Correct |
599 ms |
2136 KB |
Output is correct |
8 |
Correct |
1349 ms |
4012 KB |
Output is correct |
9 |
Correct |
2260 ms |
6772 KB |
Output is correct |
10 |
Correct |
1079 ms |
3440 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Execution timed out |
2529 ms |
1040 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
348 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
2 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
472 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
37 |
Correct |
2 ms |
348 KB |
Output is correct |
38 |
Correct |
1 ms |
348 KB |
Output is correct |
39 |
Correct |
2 ms |
348 KB |
Output is correct |
40 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
348 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
2 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
472 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
37 |
Correct |
2 ms |
348 KB |
Output is correct |
38 |
Correct |
1 ms |
348 KB |
Output is correct |
39 |
Correct |
2 ms |
348 KB |
Output is correct |
40 |
Correct |
1 ms |
348 KB |
Output is correct |
41 |
Correct |
2 ms |
344 KB |
Output is correct |
42 |
Correct |
7 ms |
348 KB |
Output is correct |
43 |
Correct |
11 ms |
348 KB |
Output is correct |
44 |
Correct |
21 ms |
348 KB |
Output is correct |
45 |
Correct |
65 ms |
508 KB |
Output is correct |
46 |
Correct |
32 ms |
528 KB |
Output is correct |
47 |
Correct |
47 ms |
348 KB |
Output is correct |
48 |
Correct |
87 ms |
548 KB |
Output is correct |
49 |
Correct |
145 ms |
604 KB |
Output is correct |
50 |
Correct |
89 ms |
608 KB |
Output is correct |
51 |
Correct |
157 ms |
684 KB |
Output is correct |
52 |
Correct |
216 ms |
684 KB |
Output is correct |
53 |
Correct |
27 ms |
344 KB |
Output is correct |
54 |
Correct |
60 ms |
348 KB |
Output is correct |
55 |
Correct |
96 ms |
348 KB |
Output is correct |
56 |
Correct |
35 ms |
348 KB |
Output is correct |
57 |
Correct |
82 ms |
344 KB |
Output is correct |
58 |
Correct |
102 ms |
348 KB |
Output is correct |
59 |
Correct |
100 ms |
348 KB |
Output is correct |
60 |
Correct |
81 ms |
552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2532 ms |
6884 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
25 ms |
532 KB |
Output is correct |
6 |
Correct |
142 ms |
864 KB |
Output is correct |
7 |
Correct |
599 ms |
2136 KB |
Output is correct |
8 |
Correct |
1349 ms |
4012 KB |
Output is correct |
9 |
Correct |
2260 ms |
6772 KB |
Output is correct |
10 |
Correct |
1079 ms |
3440 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Execution timed out |
2529 ms |
1040 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |