Submission #222098

#TimeUsernameProblemLanguageResultExecution timeMemory
222098VEGAnnKisik (COCI19_kisik)C++14
90 / 90
371 ms24988 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define ft first #define sd second using namespace std; typedef long long ll; const int N = 1000100; const ll OO = 1e18; priority_queue<int> st; pii a[N]; int n, k; ll sm = 0ll, ans = OO; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); // freopen("in.txt","r",stdin); cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i].sd >> a[i].ft; sort(a, a + n); for (int i = 0; i < n; i++){ st.push(a[i].sd); sm += a[i].sd; if (i >= k){ sm -= st.top(); st.pop(); } if (i + 1 >= k) ans = min(ans, ll(a[i].ft) * sm); } cout << ans; return 0; }
#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...