Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2010
1,509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. The Siruseri Welfare Association has organized a Cultural Programme for families in the
  2. area, to build up community spirit. The Cultural Programme is being held at the Siruseri
  3. Community Hall. Inside the hall, children perform songs and dances. Outside, local restau-
  4. rants have set up stalls selling snacks.
  5. As is typical on such an occasion, members of the audience drift in and out of the hall
  6. during the programme. An observant office bearer of the Siruseri Welfare Association notes
  7. down the times at which people enter and leave the hall. At the end of the day, he wonders
  8. what the maximum size of the audience was during the course of the programme.
  9. For convenience, he writes down each time as a single integer, the number of minutes
  10. from the start of the programme. Also, the door of the hall is narrow, so at any time, either
  11. one person can enter or one person can leave the hall, but not both. Thus, each entry and
  12. exit time that is noted down is distinct.
  13. For example, suppose the observations noted down are the following. Each line denotes
  14. the entry time and exit time of one person. (The identity of the person is not important�the
  15. same person may enter and leave the hall many times. For instance, in the example below,
  16. it might well be that the entries and exits recorded at Serial Nos 2 and 5 refer to the same
  17. person.)
  18. Serial No Enters at Leaves at
  19. 1 1 7
  20. 2 2 4
  21. 3 6 9
  22. 4 3 8
  23. 5 5 10
  24. In this example, the maximum size of the audience during the programme was 4. This
  25. was achieved between time 6 and 7.
  26. Your task is to read the list of entry and exit times and compute the maximum size of
  27. the audience during the programme.
  28. Input format
  29. The first line of input is a single integer, N, the number of entries and exits recorded. This
  30. is followed by N lines of input. Each of these lines consists of two integers, separated by
  31. a space, describing one entry and exit. The first integer is the entry time and the second
  32. integer is the exit time.
  33. Output format
  34. A single integer, denoting the maximum size of the audience during the performance.
  35. 1
  36. Test data
  37. For all inputs, 1  N  105. In 70% of the cases, N  5000. The entry and exit times for
  38. each person are in the range {0, 1, . . . , 107}. All entry and exit times are guaranteed to be
  39. distinct. For each person, the entry time is guaranteed to be strictly before the exit time.
  40. Example
  41. Sample input
  42. 5
  43. 1 7
  44. 2 4
  45. 6 9
  46. 3 8
  47. 5 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement