Submission #258020

#TimeUsernameProblemLanguageResultExecution timeMemory
258020Vladikus004Kisik (COCI19_kisik)C++14
90 / 90
1488 ms67924 KiB
#include <bits/stdc++.h> #define inf 2e9 #define ff first #define ss second #define int long long #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef long double ld; typedef pair <int, int> pii; const int N = 1000000 + 3; int n, k, cur; pii a[N]; vector <int> mxs; multiset <int> ms; bool cmp(pii a, pii b){ return a.ss < b.ss; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); #endif // LOCAL cin >> n >> k; for (int i = 0; i < n; i++){ cin >> a[i].ff >> a[i].ss; mxs.push_back(a[i].ss); } sort(a, a + n, cmp); sort(all(mxs)); mxs.resize(unique(all(mxs)) - mxs.begin()); int j = 0; ll ans = inf * 1LL * inf; for (int i = 0; i < mxs.size(); i++){ while (j < n && a[j].ss <= mxs[i]){ if (ms.size() < k) { ms.insert(a[j].ff); cur += a[j].ff; }else if (*ms.rbegin() > a[j].ff){ cur -= *ms.rbegin(); ms.erase(ms.lower_bound(*ms.rbegin())); cur += a[j].ff; ms.insert(a[j].ff); } j++; } if (ms.size() == k){ ans = min(ans, cur * 1LL * mxs[i]); } } cout << ans; }

Compilation message (stderr)

kisik.cpp: In function 'int32_t main()':
kisik.cpp:39:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < mxs.size(); i++){
                     ~~^~~~~~~~~~~~
kisik.cpp:41:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (ms.size() < k) {
                 ~~~~~~~~~~^~~
kisik.cpp:53:23: 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...