CSES - Leirikisa 1 - Results
Submission details
Task:lopov
Sender:Kuha
Submission time:2016-07-27 17:03:36 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:15:20: error: no matching function for call to 'std::multiset<int>::multiset(int&)'
   multiset<int> w(k);
                    ^
input/code.cpp:15:20: note: candidates are:
In file included from /usr/include/c++/4.8/set:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/4.8/bits/stdc++.h:86,
                 from input/code.cpp:1:
/usr/include/c++/4.8/bits/stl_multiset.h:214:7: note: std::multiset<_Key, _Compare, _Alloc>::multiset(std::initializer_list<_Tp>, const _Compare&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::multiset<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]
       multiset(initializer_list<value_type> __l,
       ^
/usr/include/c++/4.8/bits/stl_multiset.h:214:7: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
/usr/include/c++/4.8/bits/stl_multiset.h:200:7: note: std::multiset<_Key, _Compare,...

Code

#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define N (1<<17)
#define M 1000000007

using namespace std;

pair<int, int> v[300001];

int main () {
  int n, k;
  cin>>n>>k;
  ll ans = 0;
  multiset<int> w(k);
  for (int i; i <n; i++) {
    cin>>v[i].second>>v[i].first;
  }
  for (int i = 0; i < k; i++) {
   cin>>w[i];
  }
  sort(v, v + n);
  for (int i = n - 1; i >= 0; i--) {
      auto p = lower_bound(w.begin(), w.end(), v[i].second);
      if (p != w.end()) {
	w.erase(p);
	ans += (ll)v[i].first;
      }
  }
  cout<<ans<<endl;
}