-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaekjoon17273.cpp
More file actions
48 lines (42 loc) · 786 Bytes
/
baekjoon17273.cpp
File metadata and controls
48 lines (42 loc) · 786 Bytes
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
#include <iostream>
#include <vector>
using namespace std;
class card {
public:
int frt;
int back;
bool status;
card(int front, int back) {
this->frt = front;
this->back = back;
this->status = true;
}
};
int N, M, A, B, K, score;
vector<card> v;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> A >> B;
card c(A, B);
v.push_back(c);
}
for (int i = 0; i < M; i++) {
cin >> K;
for (int j = 0; j < v.size(); j++) {
if (v[j].status && v[j].frt <= K)
v[j].status = false;
else if (!v[j].status && v[j].back <= K)
v[j].status = true;
}
}
for (int i = 0; i < v.size(); i++) {
if (v[i].status)
score += v[i].frt;
else if (!v[i].status)
score += v[i].back;
}
cout << score;
}