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

×

TSECJ03 - Editorial

PROBLEM LINK:

Contest link

Editorialist: Kaustubh Khavnekar

DIFFICULTY:

Easy

PREREQUISITES:

Set theory

PROBLEM:

Matt's factory has X types of chocolates manufactured, he wants to buy another factory such that types of chocolate (and not the quantity) manufactured by his company is maximised.

QUICK EXPLANATION:

Express types of chocolates manufactured as sets, and find union with maximum cardinality.

EXPLANATION:

The types of chocolate manufactured by a factory can be modelled as a set. For example, if list of machines in a factory is 4 2 2 3 , the set for that factory is {4,2,3}. Make a set of types of chocolate manufactured by Matt's factory. Similarly make a set of types of chocolate manufactured by every other factory. Find union of each of these sets with Matt's set, the required factory will be the one with maximum union set cardinality (number of elements of the set). If more than one factory has the same cardinality which is the maximum, choose the factory with lower identification number, as stated.

SOLUTION:

C++ solution
Java solution

This question is marked "community wiki".

asked 01 Jul '17, 21:26

mp4_4's gravatar image

3★mp4_4
1
accept rate: 0%

edited 01 Jul '17, 23:24

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,499
×3,710
×155

question asked: 01 Jul '17, 21:26

question was seen: 258 times

last updated: 01 Jul '17, 23:24