Company: Autodesk_11april
Difficulty: medium
Unique Bytes Received Problem Description A team of astronauts aboard a spaceship is receiving a research file from Earth. The file arrives in segments , and each segment carries one contiguous block of the file's bytes. Segment i is described by two integers first[i] and last[i] : it delivers every byte whose index lies between first[i] and last[i] , inclusive . Byte indices are 1-based . Segments arrive in the order they are given. They may overlap an earlier segment, sit entirely inside one, or repeat one exactly, so a byte may be delivered many times but is only ever counted once. After each segment arrives, report how many distinct bytes of the file the crew now holds in total, counting everything received from the first segment up to and including that one. Input Format The first line contains a single integer n -- the number of segments. Each of the next n lines contains two space-separated integers first[i] and last[i] , the index of the first and of the last byte delivered by