My issue
Hii,
My approach is I’m traversing a loop from 0 to n-1 and applying the condition that if(A[i]>2B[i] or B[i]>2A[i]) and in cout I’m doing n-unhappy.
My code
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n,unhappy=0;
cin>>n;
int A[n],B[n];
for(int i=0;i<n;i++)
{
cin>>A[i];
cin>>B[i];
}
for(int i=0;i<n;i++)
{
if(A[i]>(2*B[i]) or B[i]>(2*A[i]))
{
unhappy++;
}
}
std::cout << n-unhappy << std::endl;
}
return 0;
}
Learning course: Arrays using C++
Problem Link: CodeChef: Practical coding for everyone