#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=2e5;
const ll inf=1e8;
const ll mod=1e9+7;
ll n,k;
struct qq
{
ll a,b;
bool operator<(const qq&o)
{
if(b==o.b) return a<o.a;
return b<o.b;
}
}a[maxN];
using ld=long double;
ld dp[2][505][505];
void solve()
{
cin >> n >> k;
for(int i=1;i<=n;i++)
{
cin >> a[i].a >> a[i].b;
if(a[i].b==-1) a[i].b=1e14;
}
sort(a+1,a+n+1);
for(int i=0;i<=n;i++)
{
for(int j=0;j<=k;j++) dp[0][i][j]=inf;
}
dp[0][0][0]=0;
for(int i=1;i<=n;i++)
{
for(int j=0;j<=n;j++)
{
for(int q=0;q<=k;q++)
{
dp[i&1][j][q]=dp[(i-1)&1][j][q];
//lay vote
if(q>=1) dp[i&1][j][q]=min(dp[i&1][j][q],dp[(i-1)&1][j][q-1]+(ld)a[i].a/(j+1));
//lay nguoi
if(j>=1&&q>=1&&a[i].b<=1000) dp[i&1][j][q]=min(dp[i&1][j][q],dp[(i-1)&1][j-1][q-1]+(ld)a[i].b/(j));
}
}
}
ld ans=inf;
//cout << dp[1][1][1]<<'\n';
for(int j=0;j<=n;j++)
{
ans=min(ans,dp[n&1][j][k]);
}
cout << fixed<< setprecision(5)<<ans;
}
int main()
{
fastio
//freopen(TASKNAME".INP","r",stdin);
//freopen(TASKNAME".OUT","w",stdout);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
139 ms |
5132 KB |
Output is correct |
6 |
Correct |
232 ms |
6272 KB |
Output is correct |
7 |
Correct |
499 ms |
8240 KB |
Output is correct |
8 |
Correct |
764 ms |
8248 KB |
Output is correct |
9 |
Correct |
944 ms |
8252 KB |
Output is correct |
10 |
Correct |
704 ms |
8148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
139 ms |
5132 KB |
Output is correct |
6 |
Correct |
232 ms |
6272 KB |
Output is correct |
7 |
Correct |
499 ms |
8240 KB |
Output is correct |
8 |
Correct |
764 ms |
8248 KB |
Output is correct |
9 |
Correct |
944 ms |
8252 KB |
Output is correct |
10 |
Correct |
704 ms |
8148 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
451 ms |
6612 KB |
Output is correct |
13 |
Correct |
403 ms |
6732 KB |
Output is correct |
14 |
Correct |
329 ms |
6612 KB |
Output is correct |
15 |
Correct |
1096 ms |
8248 KB |
Output is correct |
16 |
Correct |
936 ms |
8256 KB |
Output is correct |
17 |
Correct |
768 ms |
8244 KB |
Output is correct |
18 |
Correct |
1678 ms |
8248 KB |
Output is correct |
19 |
Correct |
1341 ms |
8252 KB |
Output is correct |
20 |
Correct |
1038 ms |
8252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1672 ms |
8248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
139 ms |
5132 KB |
Output is correct |
6 |
Correct |
232 ms |
6272 KB |
Output is correct |
7 |
Correct |
499 ms |
8240 KB |
Output is correct |
8 |
Correct |
764 ms |
8248 KB |
Output is correct |
9 |
Correct |
944 ms |
8252 KB |
Output is correct |
10 |
Correct |
704 ms |
8148 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
451 ms |
6612 KB |
Output is correct |
13 |
Correct |
403 ms |
6732 KB |
Output is correct |
14 |
Correct |
329 ms |
6612 KB |
Output is correct |
15 |
Correct |
1096 ms |
8248 KB |
Output is correct |
16 |
Correct |
936 ms |
8256 KB |
Output is correct |
17 |
Correct |
768 ms |
8244 KB |
Output is correct |
18 |
Correct |
1678 ms |
8248 KB |
Output is correct |
19 |
Correct |
1341 ms |
8252 KB |
Output is correct |
20 |
Correct |
1038 ms |
8252 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |