# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96698 | nandonathaniel | Kisik (COCI19_kisik) | C++14 | 699 ms | 54604 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 LL MAXN=1000000;
vector<LL> rec[MAXN+5];
priority_queue<LL> PQ;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
LL n,k,h,w;
cin >> n >> k;
for(LL i=1;i<=n;i++){
cin >> w >> h;
rec[h].push_back(w);
}
LL res=0;
LL ans=2e18;
for(LL i=1;i<=MAXN;i++){
for(LL j=0;j<rec[i].size();j++){
res+=rec[i][j];
PQ.push(rec[i][j]);
if(PQ.size()==k){
ans=min(ans,res*i);
LL gede=PQ.top();
PQ.pop();
res-=gede;
}
}
}
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... |