forked from 123456789asdfjkl/csp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path201809-2.cpp
More file actions
33 lines (31 loc) · 690 Bytes
/
Copy path201809-2.cpp
File metadata and controls
33 lines (31 loc) · 690 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
#include "stdio.h"
#include "vector"
#include "algorithm"
struct time {
int s;
int e;
};
int main() {
int n;
std::vector<time> H, W;
time temp;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d%d", &temp.s, &temp.e);
H.push_back(temp);
}
for (int i = 0; i < n; ++i) {
scanf("%d%d", &temp.s, &temp.e);
W.push_back(temp);
}
int sum = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (H[i].e > W[j].s && H[i].s < W[j].e) {
sum += std::min(H[i].e, W[j].e) - std::max(H[i].s, W[j].s);
}
}
}
printf("%d", sum);
return 0;
}