Submission #801942

#TimeUsernameProblemLanguageResultExecution timeMemory
801942Trisanu_DasKisik (COCI19_kisik)C++17
90 / 90
974 ms65504 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e6 + 10; const ll inf = 1e18; pair<int, int> a[maxn]; int main(){ ios_base::sync_with_stdio(false); int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i].second >> a[i].first; sort(a, a + n); multiset<int> s; ll answer = inf; ll sum = 0; for (int i = 0; i < n; i++){ s.insert(a[i].second); sum += a[i].second; if (s.size() > k){ auto it = s.end(); it --; sum -= *it; s.erase(it); } if (s.size() == k) answer = min(answer, 1ll * sum * a[i].first); } cout << answer << endl; }

Compilation message (stderr)

kisik.cpp: In function 'int main()':
kisik.cpp:24:16: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   if (s.size() > k){
      |       ~~~~~~~~~^~~
kisik.cpp:30:16: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |   if (s.size() == k)
      |       ~~~~~~~~~^~~~
#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...