-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2015D-B2.cpp
More file actions
58 lines (47 loc) · 1.39 KB
/
Copy path2015D-B2.cpp
File metadata and controls
58 lines (47 loc) · 1.39 KB
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
#include <iostream>
#include <vector>
#include <fstream>
#define FASTIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
int main() {FASTIO;
ifstream fin("speeding.in");
ofstream fout("speeding.out");
int N, M;
fin >> N >> M;
vector<int> road_segments(N), road_speeds(N);
vector<int> cow_segments(M), cow_speeds(M);
for (int i = 0; i < N; i++) {
fin >> road_segments[i] >> road_speeds[i];
}
for (int i = 0; i < M; i++) {
fin >> cow_segments[i] >> cow_speeds[i];
}
int infraction_difference = 0;
for (int i = 0; i < 100; i++) {
int segment = 0;
int speed_limit = 0;
for (int j = 0; j < N; j++) {
segment += road_segments[j];
if (i < segment) {
speed_limit = road_speeds[j];
break;
}
}
segment = 0;
int her_speed = 0;
for (int j = 0; j < M; j++) {
segment += cow_segments[j];
if (i < segment) {
her_speed = cow_speeds[j];
break;
}
}
if (her_speed - speed_limit > infraction_difference) {
infraction_difference = her_speed - speed_limit;
}
}
fout << infraction_difference << "\n";
fin.close();
fout.close();
return 0;
}