Download file
Question : Download file (Codechef Problem)
Problem Code: DWNLD
Solution in C++ :
#include <iostream>
using namespace std;
int main() {
int tc; //testcase
cin>>tc;
for(int j=0;j<tc;j++)
{
int number,k,temp=0,net,price=0;
cin>>number>>k;
for(int i=0;i<number;i++)
{
int t,d; //time and data
cin>>t>>d;
temp=temp+t;
if(temp>k)
{
net = temp-k;
if(net<t){
price=net*d;
}
else
price=price+(t*d);
}
}
cout<<price<<"\n";
}
return 0;
}
Comments
Post a Comment