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