Akash loves listening to music while jogging and wants to set up a new regime for his jogging with an app named "Jog track" on his new ipod. He would complete his workout based on the playlist time.
Initially, he sets an expected workout time D for the jog. Then, he chooses N songs to be played while jogging. The songs are denoted as S and T, where Si is the Song Number and Ti is the number of times he listens to the particular song. Here, a song may get repeated as he is obsessed with some of the songs.
He now needs to find out his ideal workout time Z for the day. Z is calculated by the following algorithm:
Step 1 - Add up all T to get a sum X.
Step 2 - Multiply X with unique number of songs (by removing the duplicates) to get Y.
Step 3 - All the songs are sorted in descending order according to its corresponding time T If a song is played more than one number of times, consider the song which has the lowest value of T .The sorted songs are given sequence number 0, 1, 2 ...
Step 4 - Multiply T of each unique songs with the sequence number to get different products Pi.
Step 5 - Sort all the products Pi in increasing order and start subtracting each P from Y. Note that each time Y is getting smaller and the last value of Y is Z.
Step 6 - Print Z.
Next, subtract D from Z and print the result R.
Now, Z is compared to D and if :
I) Z is less than D, he did not complete his expected workout time D which he had set before the jog. Hence print "<" (without quotes). .
II) Z is equals to D, he has completed his expected workout time D. Hence print "=" (without quotes).
III) Z is more than D, he has completed more time than the his expected workout time D. Hence print ">" (without quotes).
Write a program to illustrate this scenario by reading the input from STDIN and the output from STDOUT. You should not write arbitrary strings while reading the input and while printing as these contribute to the standard output.
template:
Input Format: The first line of input contains D, the expected workout time for the jog Akash sets. The second line of input contains the number of songs N he intends to listen. The next N lines contain the following: The song track Si and the number of minutes Ti for which he listens that song. Si and Ti are separated by a single white space.
Output Format: The first line of the output contains Z, the ideal workout time for today. The second line of the output contains R. The last line of output contains one of the following: "<", "=" or ">".
Sample Inputl :
12
6
5 2
1 6
2 3
6 10
5 2
1 2
output:
87
75
>
code in c
template:
# include
void getResult(int D, int N, int soundTrack[][2]){
//complete code
}
int main()
{ int D,N;
scanf("%d", &D);
scanf("%d", &N);
int soundTrack[N][2];
for(int i=0; i {
scanf("%d", &soundTrack[i][0]);
scanf("%d", &soundTrack[i][1]);}
getResult(D, N, soundTrack);
return 0;
}
follow all the steps properly while giving a code