This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,k;
cin >> n >> k;
int a[n],b[n];
bool got = false;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
if (b[i] != -1) got = true;
}
sort(a,a+n);
int h = 0;
if (!got) {
for (int i = 0; i < k; i++) {
h += a[i];
}
} else {
sort(b,b+n);
int i = 0;
while (k != 0) {
if (i == 0)
h += a[0] + b[0];
i++;
k--;
h += (a[i]/2);
}
}
cout << h << endl;
}
# | 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... |