문제

https://www.acmicpc.net/problem/2455

설명

문제를 이해하면 알고리즘을 짜는건 5분도 안걸리는 문제였던 것 같다, 먼저 반복문을 이용해 1번역에서 4번역까지 내리고 탄 사람 수를 계산 하도록 하고 각 케이스를 입력받을 때 마다 총 인원수 변수에 가감계산을 하도록 하고 처음 최댓값 변수를 0로 두고 입력받을때마다 최댓값 변수와 현재 인원수를 비교하도록 하면 끝.

코드

#include <stdio.h>

int main() {
    int total = 0, max = 0;
    for (int i=0; i<=3; i++)
    {
        int in, out;
        scanf("%d %d",&out,&in);
        total -= out;
        total += in;
        if (max < total)
            max = total;
    }
    printf("%d\n", max);

    return 0;
}