Need Help - april cookOff problem - lift requests -

please help me. what’s wrong with my code. It didn’t succeed when i submit.

#include <stdio.h>
#include<math.h>
int main(void) {
	// your code goes here
	int t,n,q;
	scanf("%d",&t);
	while(t--){
	    scanf("%d%d",&n,&q);
	    int f,d,i=0,floorCount=0,currentFloor=0;
	    for(i=0;i<q;i++){
	        scanf("%d%d",&f,&d);
	    
            floorCount+= abs(currentFloor-f) + abs(d-f);
	        currentFloor = d;

	        }
	    printf("%d\n",floorCount);
	}
	return 0;
}

Use long double data type for floorCount, as the sum goes above the int range

yes thank you shyam. yesterday it wont run for me in contest. :face_with_head_bandage:

Your code is correct … you can also check video editor of other questions :smile:

yes okay thank you shivam.