Problem:
Please find the problem here.
Solution:
This is the simplest problem I ever had, just implement the given formulas! However, it does take me some time to write.
Code:
Please find the problem here.
Solution:
This is the simplest problem I ever had, just implement the given formulas! However, it does take me some time to write.
Code:
The code is explained below using Comments(//)
//http://codeforces.com/problemset/problem/588/A
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<=b;i++) // Loop starts from a and ends at b
main(){
int n,a,p;
cin>>n; //Input taken
int mi =200;
int cost=0;
REP(i,0,n-1){
cin>>a;
cin>>p;
mi=min(mi,p); //Finding the minimum and replacing the minimum.
cost =cost+(a*mi); // Multiplying minimum with required amount .
} // Add to Cost
cout<<cost<<endl;
}
No comments:
Post a Comment