TABLET - Editorial

ad-hoc
cakewalk
cook103
editorial
implementation

#1

PROBLEM LINK:

Practice
Contest

Author: Hasan Jaddouh
Tester: Michael Nematollahi
Editorialist: Hussain Kara Fallah

DIFFICULTY:

Cakewalk

PREREQUISITES:

NONE

PROBLEM:

Chef has visited some tablet shops and listed all of his options. In total, there are N available tablets, numbered 1 through N. For each valid i, the i_{th} tablet has width W_i, height H_i and price P_i.

Chef’s budget is equal to B. He wants to buy the tablet with the largest screen (largest area) as long as its price fits with in the budget.

EXPLANATION:

This problem is a straightforward implementation. Read all the information about the tablets. The screen area of a tablet is equal to the screen’s width multiplied by the screen’s height. Iterate through all tablets and check for each one if its price is less than or equal to B. If so, compare its area to the answer and update the answer to the maximum of them.

To fully understand, it’s better to check one of the implementations attached below.

AUTHOR’S AND TESTER’S SOLUTIONS:

AUTHOR’s solution

TESTER’s solution


#2

Video Editorial : https://youtu.be/4sc_dNmcqeg