Codevita
Codevita
Welcome Home Coding Arena Compile & Run Submissions Graphs Feedback
Time Left
Coding Arena 06 00 00
Change Default Language hr min sec
A B C D E F G H
You are living in a hostel and your hostel owner decided to charge extra for electricity consumption. To achieve this he put one
separate electricity meter for every room and connected all those meters to central meter. Status messages
But the hostel owner is a bit greedy and wants to manipulate the meters to show a reading that is more than the actual
consumption of electricity. He also encrypted all the meters with alphabets. The technique he used for encrypting is as follows:
If the alphabet next to J is A, then J represents 0. Similarly, if the alphabet after I is B, then I counts as 1 (and not 8), the
alphabet after H is C, then H represents 2. The same is true if D follows G and if E follows F. Note that A, B, C, D and E will
always retain their respective values.
When J is not followed by A, J will represent 9 and similar rules for I, H, G and F
You are given central meter reading and encrypted readings of all the meters in the hostel. Your task is to find out whether the
owner is Greedy or Innocent. If he is greedy then print the unit difference otherwise print innocent.
Input Format:
First line contains an integer N, giving the number of rooms in the hostel.
The next line contains N strings each of length 6 characters giving the readings of the meters in the rooms
The next line contains an integer that gives the reading in the central meter
Output Format:
If the first line is GREEDY, the next line should contain the difference (as a decimal number) between the central meter reading
and the consumption shown in the rooms.
Constraints:
Example 1
Input
3
JAABHF JAACJA JAACDA
500
Output
GREEDY
105
https://www.tcscodevita.com/CodevitaV6/problemstart.jsp 1/2
11/08/2017 TCS: CodeVita - Coding Arena
Explanation
In the reading JAABHF, J represents 0 since it is followed by A, and hence the reading is 000175. Similarly, the other readings
are 000200 and 000230. The total of the readings in the rooms is 605 and the central meter reading is 500. Thus the owner is
GREEDY and he stole 605-500 = 105 units.
Example 2
Input
8
JAACJA JAABCH JAABHD JAACAF JAJAJJ JAABEJ JAACJJ JAACDI
1500
Output
INNOCENT
Explanation
The readings are,
The sum of these readings is 1490 < 1500, the central meter reading. Hence the owner is INNOCENT.
Note:
Please do not use package and namespace in your code. For object oriented languages your code should be written in one
class.
Note:
Participants submitting solutions in C language should not use functions from <conio.h> / <process.h> as these files do not
exist in gcc
Note:
Submit Answer
Select Language
Select File
Browse...
© 2017 Tata Consultancy Services Limited. All Rights Reserved. In Association with | Privacy Policy
https://www.tcscodevita.com/CodevitaV6/problemstart.jsp 2/2