• Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
CODE OF GEEKS

We at CODE OF GEEKS, aim at providing best and quality content for our users at no extra cost.

    • Study Materials – Company wise
      • Infosys Archive
      • Accenture Archive
      • AMCAT Archive
      • Capgemini Archive
      • Cisco Archive
      • CoCubes Archive
      • Cognizant(CTS) Archive
      • Dell Archive
      • Deloitte Archive
      • DXC Archive
      • Goldman Sachs Archive
      • Hexaware Technologies Archive
      • LTI Archive
      • MindTree Archive
      • TCS Archive
      • Virtusa Archive
      • Wipro Archive
    • Interview Preparation – E Books
      • C Interview Questions
      • Data Structures Interview Questions
      • DBMS Interview Questions
      • HR Interview Questions
      • Java Interview Questions
      • Operating System Interview Questions
      • Python Interview Questions
      • SQL Query Interview Questions
    • Programming
      • C Programming MCQs
      • C Code Snippets – Output Questions
      • Python Code Snippets – Output Questions
    • Aptitude
      • Verbal Ability for Placements
      • Quant for Placements
    • Register
    • Login
  • [email protected]
  • ..
Login / Register
Apply Now
CODE OF GEEKS
CODE OF GEEKS
  • Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
0

Cart

TeleVision Sets

  • March 19, 2020
  • CODE OF GEEKS
  • 17


Dr. Vishnu is opening a new world class hospital in a small town designed to be the first preference of the patients in the city. Hospital has N rooms of two types – with TV and without TV, with daily rates of R1 and R2 respectively.

However, from his experience Dr. Vishnu knows that the number of patients is not constant throughout the year, instead it follows a pattern. The number of patients on any given day of the year is given by the following formula –

(6-M)^2 + |D-15| ,

where M is the number of month (1 for jan, 2 for feb …12 for dec) and D is the date (1,2…31).

All patients prefer without TV rooms as they are cheaper, but will opt for with TV rooms only if without TV rooms are not available. Hospital has a revenue target for the first year of operation. Given this target and the values of N, R1 and R2 you need to identify the number of TVs the hospital should buy so that it meets the revenue target. Assume the Hospital opens on 1st Jan and year is a non-leap year.



Constraints

Hospital opens on 1st Jan in an ordinary year

5 <= Number of rooms <= 100

500 <= Room Rates <= 5000

0 <= Target revenue < 90000000

Input Format

First line provides an integer N that denotes the number of rooms in the hospital

Second line provides two space-delimited integers that denote the rates of rooms with TV (R1) and without TV (R2) respectively

Third line provides the revenue target

Output

Minimum number of TVs the hospital needs to buy to meet its revenue target. If it cannot achieve its target, print the total number of rooms in the hospital.

Test Case

Example-1 :

Input

20

1500 1000

7000000

Output

14


Explanation

Using the formula, number of patients on 1st Jan will be 39, on 2nd Jan will be 38 and so on. Considering there are only twenty rooms and rates of both type of rooms are 1500 and 1000 respectively, we will need 14 TV sets to get revenue of 7119500. With 13 TV sets Total revenue will be less than 7000000

Example-2 :

Input

10

1000 1500

10000000

Output

10

Explanation

In the above example, the target will not be achieved, even by equipping all the rooms with TV. Hence, the answer is 10 i.e. total number of rooms in the hospital.



CODE

n=int(input())
num1,num2=map(int,input().split())
est=int(input())
res1,res2=[],[]
mon,fin=0,0
month=[31,28,31,30,31,30,31,31,30,31,30,31]
for j in range(len(month)):
    for k in range(month,month[j]+1):
        res1.append((6-(j+1))**2+abs(k-15))
    res2.append(res1)
    res1=[]
for i in range(n+1):
    for j in res2:
        for k in j:
            if(k>=n):
                t=n-i
                mon=mon+(i*num1+t*num2)
            else:
                h=n-i
                t=k-h
                if(t<=0):
                    mon=mon+(k*num2)
                else:
                    mon=mon+(t*num1+h*num2)
        fin=fin+mon
        mon=0
    if(fin>=est):
        print(i)
        break
    else:
        fin=0
else:
    print(n)


Tags: codevitatcstcs codevita 2019 coding questionstcs codevita 2020tcs codevita coding questionstcs codevita last year coding questions 2019tcs codevita questions 2019tcscodevita
  • Previous Home Lightening
  • Next War Companion

17 comments on “TeleVision Sets”

  1. Kavya says:
    May 3, 2020 at 10:28 am

    I didn’t understand the question …can anyone explain?

    Reply
    1. Sai says:
      June 19, 2020 at 3:56 pm

      Send me the code plz

      Reply
  2. rahul says:
    June 19, 2020 at 10:06 am

    yeah i can explain and also give u solution but its not possible for me to explain it in comment section

    Reply
    1. Mukesh says:
      June 19, 2020 at 12:35 pm

      Can you mail me the code ,i will try to understant it

      Reply
    2. yuvraj says:
      June 19, 2020 at 12:54 pm

      could someone please post the answer

      Reply
    3. surendra says:
      June 19, 2020 at 3:15 pm

      can you please say the code for me i didnt understand the question

      Reply
    4. hari krishna says:
      June 19, 2020 at 3:16 pm

      can you mail me the code please…

      Reply
    5. Manish says:
      June 19, 2020 at 3:27 pm

      Bro can u mail me a solution of this ques?

      Reply
    6. divya says:
      June 19, 2020 at 3:36 pm

      can u post me the code for this question please..

      Reply
    7. XYZ says:
      June 19, 2020 at 4:22 pm

      Can you mail me the code

      Reply
    8. Ajay says:
      June 19, 2020 at 5:18 pm

      can you please mail me the solution

      Reply
  3. Gnaneshwari says:
    June 19, 2020 at 2:40 pm

    could some one post television sets answer

    Reply
  4. Pingback: TCS MockVita 1 Coding Questions with Solution – CODE OF GEEKS
  5. N.HEZRON says:
    June 25, 2020 at 7:34 pm

    i coudn,t understand the question , but from input, output and explanation we can get answers like this

    #include
    #include
    using namespace std;
    inline int func(int j)
    {
    if(j>n;
    int r1,r2;//r1–>with tv,r2–>without tv
    cin>>r1>>r2;
    int rev;//target revenue
    cin>>rev;
    if(n*r1*365<rev)
    cout<rev)
    {
    n-=1;
    }
    cout<<n+2;
    }
    }

    Reply
  6. Nitin says:
    June 27, 2020 at 6:23 pm

    The code written above will give you error
    Plase check the identation carefully
    I have resolved the error:
    n=int(input())
    num1,num2=map(int,input().split())
    est=int(input())
    res1,res2=[],[]
    mon,fin=0,0
    month=[31,28,31,30,31,30,31,31,30,31,30,31]
    for j in range(len(month)):
    for k in range(1,month[j]+1):
    res1.append((6-(j+1))**2+abs(k-15))
    res2.append(res1)
    res1=[]
    for i in range(n+1):
    for j in res2:
    for k in j:
    if(k>=n):
    t=n-i
    mon=mon+(i*num1+t*num2)
    else:
    h=n-i
    t=k-h
    if(t=est):
    print(i)
    break
    else:
    fin=0
    else:
    print(n)

    Reply
  7. Nitin says:
    June 27, 2020 at 6:26 pm

    The code written above will give you an error
    In first nested for loop use 1 ranther than ‘month’ in range function
    for k in range(1,month[j]+1):
    res1.append((6-(j+1))**2+abs(k-15))
    res2.append(res1)
    res1=[]

    Reply
  8. Aasakti Agarwal says:
    July 9, 2020 at 1:17 am

    n=int(input())
    r1,r2=map(int,input().split())
    target=int(input())
    nr1=n
    nr2=0
    s=0
    flag=0
    lst=[31,28,31,30,31,30,31,31,30,31,30,31]
    while(flag==0):
    for m in range(12):
    for d in range(lst[m]):
    p=(5-m)**2 + abs(d-14)
    if p=nr2:
    c=(nr1*r1)+(nr2*r2)
    s=s+c
    elif(p-nr1)=target):
    print(nr2)
    print(s)
    flag+=1
    elif(s<target and nr2==n):
    print(n)
    flag+=1
    elif(s<target and nr2<n):
    nr1-=1
    nr2+=1
    s=0

    Output:-
    10
    1000 1500
    10000000
    10

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CODE OF GEEKS

Subscribe to Newsletter

CODE OF GEEKS

Learn | Code | Achieve

Reach us

[email protected]
We at CODE OF GEEKS, aim at providing quality content to our users at no cost.
CODE OF GEEKS

Important Pages

About us
Advertise
Privacy Policy
Terms and Conditions

Placements – Study Materials

TCS NQT     Wipro     CapGemini
Accenture     MindTree     CTS
DXC     Hexaware Technologies     AMCAT
CoCubes     Goldman Sachs     Dell
Cisco     Deloitte     Virtusa     LTI     Infosys   

Courses

  • Mail Us
  • Login/Register

Recent Posts

What is Cloud Computing | Cloud Computing Applications | Cloud Development Models| SaaS vs PaaS vs IaaS
  • October 23, 2021
What is Amazon Web Services | AWS Regions & AZs | Different AWS Services
  • October 19, 2021

Copyright 2021 CODE OF GEEKS. All Rights Reserved.

  • →