CT51919

Rohan Counts the scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the dune sea of Caravanrest with crates of scrolls, and Rohan the log keeper must account for every last one. 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 <= 1425; 0 <= s < e <= 10^9.

Example 1:

Input: 512 53216630 53216685 805432500 805432541 272364232 272364234 106911445 106911498 280693823 280693919 839103183 839103279 294467114 294467175 144512381 144512472 908794146 908794211 123268942 123268947 882665084 882665110 68435797 68435861 770914050 770914134 209486601 209486609 157001585 157001635 712393271 712393299 857471143 857471228 82013270 82013357 919007358 919007413 742245173 742245237 994441230 994441269 770193883 770193964 889242500 889242592 340683454 340683523 525072011 525072061 431482877 431482948 552406607 552406614 553207721 553207794 731925715 731925785 550235694 550235744 979256197 979256234 171069680 171069736 447576774 447576837 539825966 539826050 334266361 334266432 332123180 332123202 132679879 132679883 954073840 954073847 999342399 999342471 613509759 613509811 49…
Output: 1

Example 2:

Input: 1147 150402901 150402946 374905008 374905092 943127978 943128022 957386210 957386301 47010669 47010723 798092963 798092967 298478709 298478795 959385882 959385903 19246053 19246064 20501520 20501522 749249490 749249500 990522965 990523026 530458043 530458116 737901658 737901708 646660964 646661050 189015944 189016011 832042406 832042414 934181712 934181767 637334835 637334897 700035111 700035189 992137521 992137588 162210068 162210069 293187813 293187875 268205587 268205661 538138606 538138701 209351885 209351959 574852544 574852569 876475503 876475596 623711154 623711188 515240357 515240358 747698787 747698828 571821798 571821871 1790624 1790679 629769818 629769918 148904122 148904196 934564496 934564520 23853076 23853101 708599242 708599261 324291757 324291841 217443849 217443873 4490165…
Output: 1

Example 3:

Input: 371 644377464 644377530 241085702 241085799 704832626 704832649 89276890 89276928 946011638 946011668 968827019 968827057 953644543 953644597 585661298 585661334 97380768 97380825 931231656 931231737 919104619 919104683 382709210 382709255 299594863 299594926 541854205 541854270 540673665 540673737 340059656 340059708 704502213 704502231 750823751 750823843 317519800 317519865 583813326 583813331 396144403 396144434 101533846 101533869 142592367 142592464 680287863 680287943 558321330 558321381 6668881 6668970 614015238 614015279 903166466 903166496 525173607 525173681 384553263 384553278 323524169 323524196 330606704 330606758 211662337 211662377 13602613 13602659 94937608 94937621 448751331 448751400 356262217 356262235 549755060 549755131 502020925 502020969 887908440 887908474 13755329…
Output: 1

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Rohan Counts the scrolls - MEDIUM Coding Problem | CodeTikki