QUESTION:
APPROACH:
4 times
I found the maximum in the 4x4 matrix and the row and the coloumn which contained the maximum set to -1.
used that to find profit .
IS something wrong?
CODE:-
#include <iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
using namespace std;
int main() {
long int t,tot=0;
cin>>t;
while(t--)
{
long int i,j,n;
cin>>n;
long int f[4][4]={0};
for(i=0;i<n;i++)
{
char pic;
cin>>pic;
long int num=(pic)-'A';
long int time ;
cin>>time;
time=(time/3)-1;
f[num][time]++;
}
long int maxi=0;
long int ind1=0,ind2=0;
long int profit=0;
long int cnt=4;
while(cnt>0)
{
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
if(f[i][j]>maxi)
{
maxi=f[i][j];
ind1=i;
ind2=j;
}
}
}
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
if(i==ind1 || j==ind2)
{
f[i][j]=-1;
}
}
}
if(maxi!=0)
profit=(cnt*25)*maxi+profit;
else
profit=profit-100;
cnt--;
maxi=0;
}
tot=tot+profit;
cout<<profit<<endl;
}
cout<<tot;
return 0;
}
PLZ HELP thanks in advance!