Olympiad#4192

Olympiad

1 sekunt
128 megabaýt
Orta

teams arrived to the Informatics Olympiad. Each team consists of a_i boys and b_i girls. The participants can live in rooms with places in each. Find the minimum number of rooms needed to accommodate all the Olympiad participants, if the boys can't be settled with the girls.

Giriş

The first line contains the values of and . In the next lines the pairs of numbers a_i, b_i~(1 \le i \le n) are given. All numbers are non-negative integers not greater than .

Çykyş

Print the minimum required number of rooms.

Mysallar

1-nji mysal

Loading
Loading