Help me in solving TLG problem (Why am I falling the test cases....)

My issue

I am falling a hidden test case …can anyone with membership check out what test case am i falling and inform me … idk what is wrong with my code

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n ; 
	cin >> n ;
	int lead = 0 ;
	int win = 0 ;
	
	for ( int i = 0 ; i <n ; i++){
	    
	    int a , b ; 
	    cin >> a >> b ;
	    
	    int score = abs(a-b);
	 
	 
	 if (score > lead){
	     
	     lead = score;
	     
	     a>b? win =1 : win = 2 ;
	 }
	 
}
        cout <<win<<" "<<lead;
}

Problem Link: TLG Problem - CodeChef

@justdoit01
the thing r missing is that the score in the next rounds are added up with the previous ones.
i have corrected this in your code hope u will get it.

include <bits/stdc++.h>
using namespace std;

int main() {
int n ;
cin >> n ;
int lead = 0 ;
int win = 0 ;
int a=0,b=0;
for ( int i = 0 ; i <n ; i++){

    int a1 , b1 ; 
    cin >> a1 >> b1 ;
    a+=a1;
    b+=b1;
    
    int score = abs(a-b);
 
 
 if (score > lead){
     
     lead = score;
     
     a>b? win =1 : win = 2 ;
 }

}
cout <<win<<" "<<lead;
}

1 Like

thank you … much appreciated :slightly_smiling_face: