-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsofteerGBC.cpp
More file actions
39 lines (36 loc) · 867 Bytes
/
softeerGBC.cpp
File metadata and controls
39 lines (36 loc) · 867 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
#include<iostream>
#include<vector>
using namespace std;
int N, M, maximum;
vector<pair<int, int>> arr1;
vector<pair<int, int>> arr2;
int nidx, midx;
int main(int argc, char** argv)
{
cin >> N >> M;
int temp1, temp2;
for (int i = 0; i < N; i++) {
cin >> temp1 >> temp2;
if (i != 0) temp1 += arr1.back().first;
arr1.push_back(make_pair(temp1, temp2));
}
for (int i = 0; i < M; i++) {
cin >> temp1 >> temp2;
if(i!=0) temp1 += arr2.back().first;
arr2.push_back(make_pair(temp1, temp2));
}
int comp1, comp2;
while (nidx < N && midx < M) {
comp1 = arr2[midx].second - arr1[nidx].second;
if (maximum < comp1) maximum = comp1;
if (arr1[nidx].first > arr2[midx].first) {
midx++;
}
else if (arr1[nidx].first == arr2[midx].first) {
nidx++; midx++;
}
else nidx++;
}
cout << maximum;
return 0;
}