#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
#define double long double
int INF=1e9;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
int k;cin>>k;
vector<int> a(n),b(n);
for(int i=0;i<n;i++){
cin>>a[i];
cin>>b[i];
if(b[i]==-1){
b[i]=INF;
}
}
double ans=INF;
for(int i=0;i<=k;i++){
double cnt=0;
vector<bool> vis(n);
vector<int> c(n);
iota(all(c),0);
sort(all(c),[&](int i,int j){return b[i]<b[j];});
for(int j=0;j<i;j++){
int p=c[j];
vis[p]=1;
cnt+=b[p]/(double)(j+1);
}
sort(all(c),[&](int i,int j){return a[i]<a[j];});
int ptr=0;
for(int j=0;j<k-i;j++){
while(vis[c[ptr]]){
ptr++;
}
int p=c[ptr];
vis[p]=1;
cnt+=a[p]/(double)(i+1);
ptr++;
}
ans=min(ans,cnt);
}
cout<<fixed<<setprecision(9)<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
5 ms |
312 KB |
Output is correct |
8 |
Correct |
5 ms |
212 KB |
Output is correct |
9 |
Correct |
8 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
5 ms |
312 KB |
Output is correct |
8 |
Correct |
5 ms |
212 KB |
Output is correct |
9 |
Correct |
8 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
3 ms |
268 KB |
Output is correct |
14 |
Correct |
3 ms |
212 KB |
Output is correct |
15 |
Correct |
7 ms |
320 KB |
Output is correct |
16 |
Correct |
9 ms |
340 KB |
Output is correct |
17 |
Correct |
7 ms |
340 KB |
Output is correct |
18 |
Correct |
10 ms |
212 KB |
Output is correct |
19 |
Correct |
11 ms |
332 KB |
Output is correct |
20 |
Correct |
9 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
5 ms |
312 KB |
Output is correct |
8 |
Correct |
5 ms |
212 KB |
Output is correct |
9 |
Correct |
8 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
3 ms |
268 KB |
Output is correct |
14 |
Correct |
3 ms |
212 KB |
Output is correct |
15 |
Correct |
7 ms |
320 KB |
Output is correct |
16 |
Correct |
9 ms |
340 KB |
Output is correct |
17 |
Correct |
7 ms |
340 KB |
Output is correct |
18 |
Correct |
10 ms |
212 KB |
Output is correct |
19 |
Correct |
11 ms |
332 KB |
Output is correct |
20 |
Correct |
9 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |