I am not able to understand the the arrays, for loops and if conditions in the below code for the problem. Please help. NOTE: The below code is correct.
include
using namespace std;
int main() {
int t; cin>>t; int k; int sum;
for(int i=1;i<=t;i++)
{
int n;
cin>>n;
int ar[11]={};
for(int j=1;j<=n;j++)
{
int x,y;
cin>>x>>y;
if(y>ar[x-1]&&x!=9&&x!=10&&x!=11)
{
ar[x-1]=y;
}
}
sum=0;
for(int s=0;s<11;s++)
{
sum=sum+ar[s];
}
cout<<sum<<endl;
}
return 0;
}