Submission #200093

#TimeUsernameProblemLanguageResultExecution timeMemory
200093SaboonKisik (COCI19_kisik)C++14
90 / 90
1585 ms65676 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 between signed and unsigned integer expressions [-Wsign-compare]
   if (s.size() > k){
       ~~~~~~~~~^~~
kisik.cpp:30:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   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...