이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |