My issue
my approach seemed correct to me and the answer i got for my test cases are correct, but after submission it says that all the test cases internally failed. please help me debug my solution.
My code
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> leader;
vector<int> lead;
for (int i = 0; i < n; i++) {
int S, T;
cin >> S >> T;
int currentLead = abs(S - T); // Calculate absolute lead
lead.push_back(currentLead);
if (S > T) {
leader.push_back(1);
} else {
leader.push_back(2);
}
}
int maxLead = 0;
int winner = 0;
for (int i = 0; i < n; i++) {
if (lead[i] > maxLead) {
maxLead = lead[i];
winner = leader[i];
}
}
cout << winner << " " << maxLead << endl;
return 0;
}
Problem Link: Practice Coding Problem - CodeChef