#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <queue>
#include <cstring>
#include <fstream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define s second
#define inf 1000000000000000
bool cmp2(pll a, pll b){
return a.s<b.s;
}
bool cmp(pll a, pll b){
return a.f<b.f;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n, k;
cin >> n >> k;
pll arr[n];
for(int i=0;i<n;i++) cin >> arr[i].f >> arr[i].s;
for(int i=0;i<n;i++) if(arr[i].s==-1) arr[i].s=1e9;
float ans=-1, cur;
for(int i=0;i<k;i++){
cur=0.0;
sort(arr, arr+n, cmp2);
for(int j=0;j<i;j++) cur+=float(arr[j].s)/float(j+1);
sort(arr+i, arr+n, cmp);
for(int j=i;j<k;j++) cur+=float(arr[j].f)/float(i+1);
if(ans==-1) ans=cur;
else ans=min(ans, cur);
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
320 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
3 ms |
212 KB |
Output is correct |
7 |
Correct |
6 ms |
332 KB |
Output is correct |
8 |
Correct |
8 ms |
332 KB |
Output is correct |
9 |
Correct |
9 ms |
316 KB |
Output is correct |
10 |
Correct |
5 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
320 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
3 ms |
212 KB |
Output is correct |
7 |
Correct |
6 ms |
332 KB |
Output is correct |
8 |
Correct |
8 ms |
332 KB |
Output is correct |
9 |
Correct |
9 ms |
316 KB |
Output is correct |
10 |
Correct |
5 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
4 ms |
212 KB |
Output is correct |
13 |
Correct |
5 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
212 KB |
Output is correct |
15 |
Correct |
8 ms |
320 KB |
Output is correct |
16 |
Correct |
10 ms |
212 KB |
Output is correct |
17 |
Correct |
8 ms |
212 KB |
Output is correct |
18 |
Correct |
10 ms |
324 KB |
Output is correct |
19 |
Correct |
12 ms |
332 KB |
Output is correct |
20 |
Correct |
10 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
320 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
3 ms |
212 KB |
Output is correct |
7 |
Correct |
6 ms |
332 KB |
Output is correct |
8 |
Correct |
8 ms |
332 KB |
Output is correct |
9 |
Correct |
9 ms |
316 KB |
Output is correct |
10 |
Correct |
5 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
4 ms |
212 KB |
Output is correct |
13 |
Correct |
5 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
212 KB |
Output is correct |
15 |
Correct |
8 ms |
320 KB |
Output is correct |
16 |
Correct |
10 ms |
212 KB |
Output is correct |
17 |
Correct |
8 ms |
212 KB |
Output is correct |
18 |
Correct |
10 ms |
324 KB |
Output is correct |
19 |
Correct |
12 ms |
332 KB |
Output is correct |
20 |
Correct |
10 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
320 KB |
Output is correct |
24 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
29 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |