report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Brewing potion - FlandreOJ: Flandre Online Judge

Brewing potion

Time limit: 1000 ms
Memory limit: 256 MB
Marisa has $n$ mushrooms, $i^{th}$ mushroom has the weight $A_i$ and now she want to make some potions. A potion can be made from no more than $2$ mushrooms and their weight cannot exceed $k$. What is the minimum number of potion bottles she can make using all $n$ mushrooms (because it is easier to carry along)? ### Input - The first line contains 2 integers $n, k$. - The second line contains $n$ space-separated integers $A_i$. ### Output - Print a single integers, the minimum number of potion bottles. ### Constraints - $1 \le n \le 10^5$. - $1 \le A_i \le k \le 10^9$. ### Example Input: ``` 5 7 1 2 3 5 7 ``` Output: ``` 3 ```
Sorting
Points Sorting
Brewing potion
Smallest possible
Distance minimization
Segment
Cucumber
Maximum value arrangement
Buttons game
Building fence
Balance
Topic
Sorting
Rating 800
Solution (1) Solution