Counting Identification Cards That Clear All Gates Using Interval Intersection

We have N identification cards, numbered from 1 to N, and M gates. The i-th gate can be passed by any card whose number lies in the inclusive range [L_i, R_i]. Find the number of cards that can pass through all M gates individually. Input is given on standard input in the following format: N M L1 R1 L2 R2 ... LM RM Print a single integer: the ...

Posted on Sun, 12 Jul 2026 17:26:46 +0000 by coldkill