Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Chappu is addicted to Paneer! Nikau wants to keep her happy for n days. In order to be happy in i-th day, she needs to eat exactly a[i] kilograms of Paneer.

There is a big shop uptown and Nikau wants to buy Paneer for her from there. In i-th day, they sell Paneer for pi dollars per kilogram.

Nikau knows all numbers a1,...,an and p1,...,pn. In each day, he can buy arbitrary amount of Paneer, also he can keep some Paneer he has for the future.

Nikau is a little tired from cooking Paneer, so he asked for your help. Help him to minimize the total money he spends to keep Chappu happy for n days.

Input Format

The first line of input contains integer n (1<=n<=10^5), the number of days.

In the next n lines, i-th line contains two integers ai and pi (1<=ai, pi<=100), the amount of Paneer Chappu needs and the cost of Paneer in that day.

Constraints

1 <= n <= 10^5

Output Format

Print the minimum money needed to keep Chappu happy for n days, in one line.

Sample Input 0

3
1 3
2 2
3 1
Sample Output 0

10

What I have tried:

#include<stdio.h>
void main()
{

}
Posted
Updated 9-Sep-20 9:28am
Comments
nv3 24-May-18 12:43pm    
What you have tried looks good so far. Just continue! :-)
jeron1 24-May-18 14:01pm    
LOL A keen observation! +5!

Quote:
What is the code for below problem?

It is whatever you want it to be; whatever your mind can come up with. There is no "the code" for any problem; they can all be solved in a multitude of ways. Lose the idea that there is "one solution" to any problem in development: there almost never is.

Having said that, we do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
Comments
Member 13843140 24-May-18 12:19pm    
thank you sir
OriginalGriff 24-May-18 12:21pm    
You're welcome!
Quote:
What is the code for below problem?

this problem smells like a challenge from a site like CodeChef. All the interest is that you challenge your skills, if you fail to program a solution, not even talking about a fast algorithm, it means that you still need to improve your skills.
a programmer learns during all its life, it is never ending.
This book might help: Structured Programming.pdf[^]
Otherwise, recommend to read about "Learn Algorithms and Data-Structures"
 
Share this answer
 
Apparently you've done nothing and want the work done for you.

All but certainly homework, what do you expect to learn if you hand in OUR work? Maybe you think you're fooling your instructor, but the fool would be you. If you fake your way through school, once out in the world you'll find yourself unemployable - hired and fired like a door at a busy shop.

If this is your career choice and you already don't want to do anything but have results handed to you I suggest you find a new career. Seriously, and soon.

 
Share this answer
 
Comments
Patrice T 9-Sep-20 15:31pm    
Question is 2 years old, I fear OP is not arround anymore.
W Balboos, GHB 9-Sep-20 15:40pm    
somehow got popped to the main part of he list of active questions - makes it easy to overlook the dates. Hopefully he's enjoying driving his ice cream truck.

It was updated 10 minutes ago (!).
CHill60 10-Sep-20 4:54am    
"It was updated 10 minutes ago (!)." - Solution 4 was probably spammy - old posts still reappear at the top of the list even if the attempted solution gets blocked in the moderation queue
#include<stdio.h>
int main(){
int i,j,k,m,n,imin=20;
int ai,pi;
int ans=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d",&ai,&pi);
imin=imin>pi?pi:imin;
ans=ans+ai*imin;
}
printf("%d\n",ans);
return 0;
}
 
Share this answer
 
v2
Comments
Richard Deeming 14-Jun-18 13:22pm    
You don't help anyone by doing their homework for them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900