-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path116A.c
30 lines (22 loc) · 882 Bytes
/
116A.c
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
#include <stdio.h>
int main(){
int cases, exitPas, enterPas;
// Input cases here
scanf("%d", &cases);
getchar();
// Algorithm here
int maxPas = 0, currentPas = 0;
for (int caseCounter = 1; caseCounter <= cases; caseCounter++) {
// Input exit passenger and enter passenger count here
scanf("%d %d", &exitPas, &enterPas);
getchar();
if (caseCounter == 1) currentPas = exitPas; // Set current passenger count as exit passenger count in the first stop
else currentPas -= exitPas; // Subtract current passenger count with exit passenger count
currentPas += enterPas; // Add current passenger with enter passenger count
if (maxPas < currentPas) maxPas = currentPas; // Search for the maximum passenger count
}
// Print the output
printf("%d\n", maxPas);
getchar();
return 0;
}