I need debugging help on USACO 2015 December Contest, Bronze Problem 2. Speeding Ticket. the problem I cannot for the life of me figure out why my code is failing test case 10.
` #include
int main()
{
freopen(“speeding.in”, “r”, stdin);
freopen("speeding.out", "w", stdout);
int N;
int M;
int Portions_N[200];
int limits[200];
int Portions_M[200];
int current;
int max=0;
int speeds[200];
std::cin >> N;
std::cin >> M;
for (int x = 0; x < N; x++) {
std::cin >> Portions_N[x];
std::cin >> limits[x];
}
for (int z = 0; z < M; z++) {
std::cin >> Portions_M[z];
std::cin >> speeds[z];
}
for(int x_1 = 0; x_1 < N; x_1++ ) {
Portions_N[x_1 + 1] = Portions_N[x_1] + Portions_N[x_1 + 1];
}
for (int z_1 = 0; z_1 < N; z_1++) {
Portions_M[z_1 + 1] = Portions_M[z_1] + Portions_M[z_1 + 1];
}
for (int y = 0; y < 100; y++) {
int location[100];
int car[100];
for (int a = 0; a < N; a++) {
if (y <= Portions_N[a]) {
location[y] = limits[a];
//std::cout << limits[a] << ' ';
break;
}
else {
location[y] = limits[N];
}
}
for (int b = 0; b < M; b++) {
if (y <= Portions_M[b]) {
car[y] = speeds[b];
//std::cout << speeds[b] << ' ';
break;
}
else {
car[y] = speeds[M];
//std::cout << Portions_M[b];
}
}
//std::cout << y << "T" << car[y] << "T"<<location[y] <<"T"<< y << "T" << ' ';
current = car[y] - location[y];
//current = current * -1;
//std::cout <<"T"<< current << "T"<<' ';
if (current > max) {
max = current;
}
else { max = max; }
//std::cout << max;
//std::cout<<car[y]
//std::cout<<location[y]
}
std::cout << max;
}`
Thanks for the help.