1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
//보석도둑
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#define MAXX 300001
using namespace std;
typedef long long ll;
int n, k;
typedef pair<int, int> pp;
bool compare(const pp &a, const pp &b)
{
if (a.first > b.first)
return true;
else if (a.first == b.first)
{
if (a.second > b.second)
return true;
else
return false;
}
else
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
vector<pp> jewels;
for (int i = 0; i < n; i++)
{
int m, v;
cin >> m >> v;
jewels.push_back(pp(v, m));
}
sort(jewels.begin(), jewels.end(), compare);
multiset<int> bag;
for (int i = 0; i < k; i++)
{
int c;
cin >> c;
bag.insert(c); //자동 정렬을 위해 중복 key값이 가능한 multiset을 사용
}
ll ans = 0;
vector<pp>::iterator idx;
{
multiset<int>::iterator value = bag.lower_bound(idx->second);
if (value != bag.end())
{
ans += idx->first;
}
}
cout << ans << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
BOJ/C++