You are not logged in. Please login at www.codechef.com to post your questions!

×

FLTRCK - Editorial

PROBLEM LINK:

Practice

Contest

Author: samhenry97 Editorialist: samhenry97

DIFFICULTY:

Easy

PREREQUISITES:

Array Sum, Binary Search

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".

asked 25 May '18, 05:55

samhenry97's gravatar image

2★samhenry97
31
accept rate: 0%

edited 29 May '18, 12:50

admin's gravatar image

0★admin ♦♦
19.8k350498541

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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