My issue
Please help me debug my code, it fails for some of the testcases.
My code
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while(t--){
int n;
cin >> n;
int problem[n];
int score[n];
for(int i =0; i <n; i++){
cin >> problem[i] >> score[i];
}
int totalScore = 0;
int maxScore = 0;
for(int i = 0 ; i <n; i++){
for(int j = i+1; j < n; j++){
if(problem[i] == problem[j] && problem[i] <= 8){
maxScore = max(score[i], score[j]);
totalScore += maxScore;
}
}
}
cout << totalScore << endl;
}
return 0;
}
Problem Link: WATSCORE Problem - CodeChef