$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(): n, t = map(int, sys.stdin.readline().split()) starts = [] ends = [] for _ in range(n): l, r = map(int, sys.stdin.readline().split()) starts.append(l) ends.append(r) starts.sort() ends.sort() max_count = 0 current = 0 j = 0 for start in starts: while j < len(ends) and ends[j] <= start: current -= 1 j += 1 current += 1 if current > max_count: max_count = current print(max_count) 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.