~/algor $ cat problems/ochkoz-qayiqlar
Crossing the river
Medium
1000 ms
128 MB
56%
$n$ people have to cross a river; the weight of the $i$-th person is $w_{i}$. Each boat takes at most two people, and their total weight must not exceed $C$. Find the smallest number of boats needed to get everyone across.
Input
The first line contains two positive integers: $n$ and $C$. The second line contains $n$ space-separated positive integers $w_{i}$.
Output
One integer — the smallest number of boats.
Note
$1 \le n \le 10^{5}$
$1 \le w_{i} \le C \le 10^{9}$
Examples
Input #1
4 100 60 40 70 30
Output #1
2
Input #2
3 50 50 50 50
Output #2
3