Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Memory distribution Given a memory block of size N . You can divide the memory block in a way that fulfills the following two conditions:

Memory distribution
Given a memory block of size N. You can divide the memory block in a way that fulfills the following two conditions:
After the division, each memory block should have lengths A Bor C
After the division, the number of memary blocks should be maximum
You are given integers N A, B, and C. Print the maximuni possible number of memory blocks. It is guaranteed that at least one correct memory division exists,
Function description
Complete the function Memory This function takes the following 4 parameters and returns the required answer
N: Represents the size of the block
A Represents the first valid division length
B: Represents the second valid division length
C: Represents the third valid division length
Input format for custom testing
Note: Use this Input format if you are testing against custom input or writing code in a language where we don\'t provide boilerplate code
The first line contains an integer N denoting the size of the memory block.
The second line contains an integer A denoting the first valid
division length.
The third line contains an integer B denoting the second valid
division length The fourth line contains an integer C denoting the third valid divesion length.
Output format
Print the maximum possible number of memory blocks. It is guaranteed that at least one correct memory division. exists.
Constraints
1<=N,A,B,C <=4000
Sample input
5
5
3
2
Sample output
2
Explanation
You can divide the memory block in such a way. The first block has length 2. and the second block has length 3. The answer is 2
The following test cases are the actual test cases of this question that may be used to evaluate your submission
Sample input 1
7
5
5
2
Sample output 1
2
Sample input 2
4
4
4
4
Sample output 2
1
Note:
Your code must be able to print the sample output from the provided sample nout However your code is run against multiple hidden test cases Therefore. your code mast pass these hidden test cases to solve the problem statement
Umits
Time Unit 10 sets) for each input file Memory Limit 256 MB Source Limit 1024 KB
Scoring
Score is assigned if any lestcase Destin Allowed Languages
CCM Coque Ca. D. Filing Fritlig Proovy. Haskell jave Node na Katip Lap SECLI. Le Objective-C OCam Cave Pescal Per Pip Python Pyon Panen 38 Racket, Ruby Rust Save StypeScript Visual Rest
Code here :-
def Memory (N, A, B,C);
# Write your code here
pass
N = int(input())
A = int(input())
B = int(input())
C = int(input())
out = Memory(N, A, B, C)
print (out)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

Students also viewed these Programming questions

Question

What are the skills of management ?

Answered: 1 week ago