CONFLIP : getting runtime error

http://www.codechef.com/viewsolution/2228232

@yashvardhan90 You are reading value of variable ā€˜gā€™ only once (for first test case), not for each testcase. Fixed it. Here is your AC code.

#include<stdio.h>
#include<math.h>
 
int main()
{   int t,g,i,n,q,h;    
    scanf("%d",&t);
    while(t--)
    {
    		scanf("%d", &g); // Changed Here
              while(g--)
              {         
                        scanf("%d %d %d",&i,&n,&q);
                        
                       
                                   if (i==q||n%2==0)
                                   printf("%d\n",n/2);
                                      
                        
                                      else
                                      printf("%d\n",(n+1)/2);
                                      
              }
   
    }
   // getch();
    return 0;
}

Hope it helps, Best Luck :slight_smile:

1 Like