TopCoder SRM 149 DIV 1 Easy 練習

問題

待ち行列に人がどんどんやってきて、注文をして、食品を受け取って帰っていく。

来た順に、「いつ来たか」と「注文してから食品を受け取るまで何分かかったか」の情報が渡されるので、列に入ってから注文まで一番待たされた人は何分待たされたか求めなさい。

ハイパーやるだけ問題。

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;

public class BigBurger {
    public int maxWait(int[] arrival, int[] service) {
        int now = arrival[0] + service[0];
        int res = 0;
        for (int i = 1; i < arrival.Length; ++i)
        {
            if (arrival[i] < now)
                res = Math.Max(res, now - arrival[i]);
            else
                now = arrival[i];
            now += service[i];
        }
        return res;
    }
}