Buying New Tablet
Question : Buying New Tablet (Codechef Problem)
Solution in C++ :
#include <iostream>
using namespace std;
int main() {
int testcase,k;
cin>>testcase;
for(k=0;k<testcase;k++)
{
int number,budget,check=0,counter=0;
cin>>number>>budget;
for(int i=0;i<number;i++)
{
int width,height,price;
cin>>width>>height>>price;
if(price<=budget && check<(width*height))
{
check = width*height;
counter++;
}
}
if(counter==0)
{
cout<<"no tablet\n";
}
else
{
cout<<check<<"\n";
}
}
return 0;
}
Comments
Post a Comment