Problem Link: INCREAR Problem - CodeChef
Feedback
Kindly check if the expected output in this code is wrong because last two expected outputs should be 2 and 3.
Problem Link: INCREAR Problem - CodeChef
Kindly check if the expected output in this code is wrong because last two expected outputs should be 2 and 3.
@deepansh6_626
The sample test cases are absolutely fine .
plzz refer my c++ code for better understanding of the logic and implementation.
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
long int x,y;
cin>>x>>y;
long int diff = x - y;
if(diff <= 0){
cout<<y - x<<endl;
}
else{
long int ans=ceil(diff*1.0/2.0) + diff%2;
cout<<ans<<endl;
}
}
return 0;
}