Submission #921325

#TimeUsernameProblemLanguageResultExecution timeMemory
921325JoksimKaktusKisik (COCI19_kisik)C++17
90 / 90
1022 ms73016 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; void output(bool yes){yes ? cout << "Yes" << "\n" : cout << "No" << "\n";} int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); int n,k; cin >> n >> k; vector <pair<ll,ll>> v(n); for(int i = 0;i < n;i++){ cin >> v[i].second >> v[i].first; } std::sort(v.begin(), v.end()); multiset <ll> ml; ll sum = 0; for(int i = 0;i < k;i++){ ml.insert(v[i].second); sum += v[i].second; } ll res = sum * v[k-1].first; auto it = ml.end(); it--; for(int i = k;i < n;i++){ if(v[i].second < *it){ sum = sum + v[i].second - *it; ml.insert(v[i].second); it--; res = min(res,sum * v[i].first); } } cout << res << "\n"; }
#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...