Beginner Problem-please help! WATSCORE, unable to figure out errors

#include <bits/stdc++.h>

using namespace std;

int main()
{
int T;
cin>>T;
while(T–)
{
int N;
cin>>N;
vector<pair<int, int>> vect;
for(int i=0; i<N; i++)
{
int a, b;
cin>>a>>b;
vect.push_back(make_pair(a, b));
}
sort(vect.begin(), vect.end());
int score=0;
for(int i=0; vect[i].first<9;)
{
int max=0;
int term=vect[i].first;
while(vect[i].first==term)
{
if(max<vect[i].second)
max=vect[i].second;
i++;
}
score+=max;
}
cout<<score<<endl;
}
return 0;
}

https://www.codechef.com/submit/WATSCORE

I did not find fault with your implementation. But since it seems way more complex than it needs to be… here is a simpler implementation that got accepted.

https://www.codechef.com/viewsolution/33169182

I do have a better solution of my own, but I am unable to figure out why this isn’t being accepted. Please help me with this one :slightly_smiling_face: