$N$ persons visited a restaurant. The restaurant is open from 0 to $T$. The $i$-th…
- User
persons visited a restaurant. The restaurant is open from 0 to . The -th person entered the restaurant at and left at . Find the maximum number of persons during the business hours.
Assistant
pythonimport sys def main(): input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 T = int(input[idx]) idx += 1 events = [] for _ in range(N): l = int(input[idx]) idx += 1 r = int(input[idx]) idx += 1 events.append((l, 1)) events.append((r, -1)) events.sort() current = 0 max_people = 0 for t, delta in events: current += delta if current > max_people: max_people = current print(max_people) if __name__ == "__main__": main()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.