# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200093 | Saboon | Kisik (COCI19_kisik) | C++14 | 1585 ms | 65676 KiB |
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;
typedef long long ll;
const int maxn = 1e6 + 10;
const ll inf = 1e18;
pair<int, int> a[maxn];
int main(){
ios_base::sync_with_stdio(false);
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++)
cin >> a[i].second >> a[i].first;
sort(a, a + n);
multiset<int> s;
ll answer = inf;
ll sum = 0;
for (int i = 0; i < n; i++){
s.insert(a[i].second);
sum += a[i].second;
if (s.size() > k){
auto it = s.end();
it --;
sum -= *it;
s.erase(it);
}
if (s.size() == k)
answer = min(answer, 1ll * sum * a[i].first);
}
cout << answer << endl;
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |