Submission #104600

#TimeUsernameProblemLanguageResultExecution timeMemory
104600DMCSKisik (COCI19_kisik)C++14
90 / 90
447 ms36648 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t #define w first #define h second typedef pair<int, int> rect; const int N = 1e6; bool cmp(rect r1, rect r2) { return r1.h < r2.h; } rect b[N]; priority_queue<int> wd; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; for(int i = 0; i < n; i++) cin >> b[i].w >> b[i].h; sort(b, b+n, cmp); int ans, temp = 0; for(int i = 0; i < k-1; i++) { temp += b[i].w; wd.push(b[i].w); } ans = (temp + b[k-1].w) * b[k-1].h; for(int i = k; i < n; i++) { temp += b[i-1].w; wd.push(b[i-1].w); temp -= wd.top(); wd.pop(); int s = (temp + b[i].w) * b[i].h; ans = min(ans, s); } cout << ans; }
#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...