Submission details
Task:lopov
Sender:Hansuzu
Submission time:2016-07-27 14:42:45 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp:11:1: error: 'multisetset' does not name a type
 multisetset<long long> bags;
 ^
input/code.cpp: In function 'int tr(int)':
input/code.cpp:17:6: error: 'bags' was not declared in this scope
   it=bags.lower_bound(m);
      ^
input/code.cpp: In function 'int main()':
input/code.cpp:33:5: error: 'bags' was not declared in this scope
     bags.insert(C);
     ^
input/code.cpp:36:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<jw.size(); ++i){
                           ^

Code

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define MP make_pair
#define F first
#define S second
int N, K;
using namespace std;
multisetset<long long> bags;
set<long long>::iterator it;
vector<pair<int, int> > jw;
int tr(int m){
it=bags.lower_bound(m);
if (it==bags.end()) return 0;
bags.erase(it);
return 1;
}
int main(){
cin >> N >> K;
for (int i=0; i<N; ++i){
int M, V;
cin >> M >> V;
jw.push_back(MP(-V, M));
} sort(jw.begin(), jw.end());
for (int i=0; i<K; ++i){
long long C;
cin >> C;
bags.insert(C);
}
long long ans=0;
for (int i=0; i<jw.size(); ++i){
ans-=tr(jw[i].S)*jw[i].F;
}
cout << ans << "\n";
}