CT41902

Grey's Roving ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the old quarter of Brasshaven opens only for a perfect tally of ribbons. Grey means to find out. Task: n crews each guard a half-open interval [s,e). An interval ending at time t does not overlap one starting at t. Print the maximum number overlapping at any instant. Input format: First line: n. Next n lines: s e. Output format: Print the maximum simultaneous overlap. Constraints: 1 <= n <= 1027; 0 <= s < e <= 10^9.

Example 1:

Input: 627 264876829 264876848 231129563 231129609 811241180 811241191 580908027 580908120 215279286 215279310 221227126 221227148 747462623 747462644 139739424 139739433 714417750 714417824 119003915 119003998 981088368 981088411 172180948 172181017 388607294 388607379 632685196 632685288 768310738 768310822 802559709 802559809 52892559 52892639 769342449 769342483 196013348 196013357 589959489 589959545 484623008 484623095 695314918 695314934 956394547 956394614 26955221 26955227 312918790 312918845 791213725 791213776 706078818 706078823 876765984 876766068 601128552 601128590 304537147 304537184 719461043 719461089 162988600 162988625 812724328 812724425 610297310 610297335 856785823 856785843 378173906 378173933 181626023 181626028 855363318 855363359 895393283 895393327 263244882 263244897 …
Output: 1

Example 2:

Input: 465 75632993 75633086 277613608 277613642 556777190 556777246 465801734 465801784 752339034 752339074 124347028 124347031 419520594 419520672 350378720 350378772 443769623 443769690 459483444 459483535 429272435 429272467 801977476 801977569 700796235 700796327 285813983 285814080 896552884 896552932 178716712 178716751 419155657 419155737 39713479 39713572 408596827 408596853 814200715 814200776 707916589 707916625 617637150 617637214 127484429 127484468 31696926 31696993 385138605 385138614 77126349 77126448 399763721 399763789 969874342 969874425 440446920 440447000 542767125 542767218 198809818 198809835 76986494 76986551 984797955 984798004 629998005 629998023 46787274 46787357 461412779 461412807 523888392 523888435 190346917 190346964 35420421 35420424 922596416 922596430 465292828 …
Output: 1

Example 3:

Input: 392 407146045 407146103 291224436 291224470 511288062 511288131 549957948 549958032 307380914 307380971 954208940 954209014 258993561 258993645 835496366 835496379 517704118 517704121 545763798 545763806 368211638 368211691 769326001 769326005 756781978 756782047 2467100 2467142 306035642 306035669 685647086 685647186 275612136 275612209 261859496 261859591 977340906 977340924 888633430 888633510 266920697 266920764 897667435 897667487 414319515 414319534 884357521 884357542 637876497 637876501 269650183 269650225 587636401 587636421 992398578 992398618 125992775 125992812 974337770 974337843 808192221 808192257 299193477 299193558 644675853 644675941 252335622 252335650 43050739 43050819 157688324 157688336 919727307 919727406 547014650 547014725 32312254 32312291 203737405 203737468 1186…
Output: 1

Constraints:

1 <= n <= 1027; 0 <= s < e <= 10^9.

Loading...
Test Cases:No test cases
No test cases available.
Grey's Roving ribbons - MEDIUM Coding Problem | CodeTikki