Submission #123237

#TimeUsernameProblemLanguageResultExecution timeMemory
123237cveleKisik (COCI19_kisik)C++14
90 / 90
1289 ms52948 KiB
#include <iostream> #include <sstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cctype> #include <cstring> #include <climits> #include <iomanip> #include <bitset> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <list> #include <map> using namespace std; const int N = 1000005; int n, k; vector < pair <int, int> > vec; multiset <int> ms; int main() { ios_base::sync_with_stdio(false); cin >> n >> k; for (int i = 0; i < n; i++) { int w, h; cin >> w >> h; vec.push_back({h, w}); } sort(vec.begin(), vec.end()); int pos = 0; long long ans = 2e18, sum = 0; for (int i = 1; i < N; i++) { while (pos < n && vec[pos].first <= i) { sum += vec[pos].second; ms.insert(vec[pos].second); while (ms.size() > k) { sum -= *ms.rbegin(); ms.erase(--ms.end()); } pos++; } if (ms.size() == k) { ans = min(ans, 1ll * sum * i); } } cout << ans << endl; return 0; }

Compilation message (stderr)

kisik.cpp: In function 'int main()':
kisik.cpp:43:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       while (ms.size() > k) {
              ~~~~~~~~~~^~~
kisik.cpp:49:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (ms.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...