Submission #100529

#TimeUsernameProblemLanguageResultExecution timeMemory
100529FeederKisik (COCI19_kisik)C++11
90 / 90
365 ms28628 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, k, w, h; long long mn = 1e18, curw = 0; vector<pair<int, int> > vec; cin >> n >> k; for(int i=0; i<n; i++){ cin >> w >> h; vec.push_back(make_pair(h, w)); } priority_queue<int> pq; sort(vec.begin(), vec.end()); for(int i=0; i<k; i++){ curw += vec[i].second; pq.push(vec[i].second); } mn = min(mn, curw * vec[k-1].first); for(int i=k; i<n; i++){ if(vec[i].second >= pq.top()) continue; curw -= pq.top(); pq.pop(); curw += vec[i].second; pq.push(vec[i].second); mn = min(mn, curw * vec[i].first); } cout << mn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...