#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll u = 10000;
int main() {
ll n, k;
cin >> n >> k;
ll a[n], b[n];
vector<ll> h, nh;
for(int i=0; i<n; i++) {
cin >> a[i] >> b[i];
if(b[i]==-1) nh.push_back(a[i]);
else h.push_back(a[i]);
}
sort(h.begin(), h.end());
sort(nh.begin(), nh.end());
ll ans = (ll)1<<60;
for(int i=0; i<min(k, (ll)h.size()); i++) {
ll tot = 0, helper = 1;
for(int j=0; j<i; j++) {
tot += h[i]*u/helper;
helper ++;
}
for(int j=i;j<k; j++) {
tot += nh[i]*u/helper;
}
ans = min(tot, ans);
}
cout << (double)ans/u;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |