daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. int main() {
  6.     int N, K; cin >> N >> K;
  7.     vector<pair<int,int> > v(N);
  8.     for (int i = 0; i < N; ++i) {
  9.         cin >> v[i].second >> v[i].first;
  10.     }
  11.     sort(v.begin(), v.end(), greater<pair<int,int> >());
  12.     ll sum = 0;
  13.     ll res = 0;
  14.     multiset<int> s;
  15.     for (int i = 0; i < N; ++i) {
  16.         int b =t> s;
  17.     for (int i = 0; i < N; ++i) {
  18.         int b = v[i].first;
  19.         if (i < K) {
  20.             sum += v[i].second;
  21.             s.insert(v[i].second);
  22.         }
  23.         else {
  24.             if (v[i].second > *s.begin()) {
  25.                 sum -= *s.begin();
  26.                 sum += v[i].second;
  27.                 s.erase(s.begin());
  28.                 s.insert(v[i].second);
  29.             }
  30.  
  31.         }
  32.        
  33.         res = max(res, sum*b);
  34.     }
  35.     cout << res;
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top