×

# FLTRCK - Editorial

Practice

Contest

Author: samhenry97 Editorialist: samhenry97

Easy

# PROBLEM:

What is the largest amount of items of an array that sums to a number <= a given value?

# QUICK EXPLANATION:

We can construct a sum array, and then use binary searches for each query.

# EXPLANATION:

First, we read the integers and sort them. Then, we create an array sum, which is a cache of the sums of each subarray 0..i.

Now, for each query, we can run a binary search to see where the largest sum is that fits the weight.

# AUTHOR'S AND TESTER'S SOLUTIONS:

This question is marked "community wiki".

31
accept rate: 0%

19.8k350498541

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×15,852
×3,820
×1,056
×17
×15

question asked: 25 May '18, 05:55

question was seen: 190 times

last updated: 29 May '18, 12:50