# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200568 | Asrapogorgon | Kisik (COCI19_kisik) | C++14 | 2062 ms | 73252 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;
#define F first
#define S second
#define pb push_back
#define int long long
const int maxn=1e6+7;
/*Almost copy pasted part :)*/
using namespace std;
int n,k;
vector<pair<int, int>>vec;
multiset<int>ms;
int32_t main(){
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=1e18+7,sum=0;
for (int i=1;i<maxn;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,sum*i);
}
}
cout<<ans<<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... |