[Solved] Phone program

$25

File Name: Phone_program.zip
File Size: 122.46 KB

SKU: [Solved] Phone program Category: Tag:
5/5 - (1 vote)

Problem DescriptionYou are looking for an internship for your summer holiday. Hendys Mobile Corporation (HMC) called you for an interview at their company. HMC is a renowned company with multiple breakthrough innovations in the past few years.HMC is developing a smartphone with multiple storages functionality and they are looking for programmers to be part of the project.As part of the interview questions, you are asked to create a program to analyze how an application interacts with the multiple storages in a phone.InputThe first line of the input contains two integers, N (0 < N 100) and S (0 < S 1,000,000), where N is the number of storages in the phone and S is the storage size of each storage. The second line contains one integer, A (0 < A 100), whereA is the number of applications to be installed. The application must be installed on the first storage first, if there is enough space, before installing it on the next storage. Each line of the next A lines contains a string and an integer that represent the file name and file size accordingly. You can assume that the file name is unique and there will be no space in the name.OutputThe first A lines are the result of each installation done on the phone.The next two lines will be the name and size of the smallest and the largest application installed on the phone. If there are two or more applications with the same file size, output the first application encountered.The next N+1 lines contain the remaining size of each storage, with its storage name.Sample Input 1 Sample Output 13 10 Added to storage 14 Added to storage 2HappyBird 2 Added to storage 1IVLE 9 Failed to be addedJavaTycoon 3 HappyBird 2 KBCodeCrunch 12 IVLE 9 KBRemaining size:Storage 1: 5 KBStorage 2: 1 KBStorage 3: 10 KBExplanation 1HappyBird can be added to storage 1. The remaining free space of storage 1 is (10 2) = 8.IVLE with size 9 cannot be added to storage 1 with size 8. It can be added to storage 2. The remaining free space of storage 2 is (10 9) = 1.JavaTycoon can be added to storage 1. The remaining free space of storage 1 is (8 3) = 5.CodeCrunch cannot be added to any of the 3 storages.Page 2 of 2Sample Input 2 Sample Output 22 100 Added to storage 16 Added to storage 2HappyBird 28 Added to storage 1HANDy 75 Added to storage 1AiVeeLE 27 Failed to be addedJavaTycoon 12 Added to storage 1CrunchyCode 100 JavaTycoon 12 KBMySOCks 33 HANDy 75 KBRemaining size:Storage 1: 0 KBStorage 2: 25 KBExplanation 2HappyBird can be added to storage 1. The remaining free space of storage 1 is (100 28) = 72.HANDy with size 75 cannot be added to storage 1 with size 72. It can be added to storage 2. The remaining free space of storage 2 is (100 75) = 25.AiVeeLE can be added to storage 1. The remaining free space of storage 1 is (72 27) = 45.JavaTycoon can be added to storage 1. The remaining free space of storage 1 is (45 12) = 33.CrunchyCode cannot be added to both storages 1 and 2.MySOCks can be added to storage 1. The remaining free space of storage 1 is (33 33) = 0.Algorithm Template1. How are you going to store the applications inside a storage?2. What are the criteria for an application to be failed to be added?3. How to get the smallest/largest application?4. How to keep track on the remaining size of all storages?

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Phone program
$25