# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123237 | cvele | Kisik (COCI19_kisik) | C++14 | 1289 ms | 52948 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 <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
using namespace std;
const int N = 1000005;
int n, k;
vector < pair <int, int> > vec;
multiset <int> ms;
int main() {
ios_base::sync_with_stdio(false);
cin >> n >> k;
for (int i = 0; i < n; i++) {
int w, h;
cin >> w >> h;
vec.push_back({h, w});
}
sort(vec.begin(), vec.end());
int pos = 0;
long long ans = 2e18, sum = 0;
for (int i = 1; i < N; i++) {
while (pos < n && vec[pos].first <= i) {
sum += vec[pos].second;
ms.insert(vec[pos].second);
while (ms.size() > k) {
sum -= *ms.rbegin();
ms.erase(--ms.end());
}
pos++;
}
if (ms.size() == k) {
ans = min(ans, 1ll * sum * i);
}
}
cout << ans << endl;
return 0;
}
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... |