BOOKVSONLINE (study mode) Editorial

BOOKVSONLINE (study mode)

Problem link -LINK
Author - Aman Gupta
Tester- Aagam Jain

Difficulty : Simple
Problem Tag : Implementation , Maths

Problem :
Find the sum of all Ai and Bi and print whose sum is greater.

Explanation :
Very simple use for loop and find sum of all array elements and print whether which is great.

My Solutions :

C++ Solution

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

int main() 
{
    int t;
    cin >>t;
    while(t--)
    {
       int n;
       cin>>n;
       int arr[n];
       int arr1[n];
       int sum1=0;
       int sum2=0;
       for(int i=0;i<n;i++)
       {
           cin>>arr[i];  sum1+=arr[i];
       }
       for(int i=0;i<n;i++)
       {
           cin>>arr1[i]; sum2+=arr1[i];
       }
       if(sum1>=sum2)
       cout<<"BOOK"<<"\n";
       else
       cout<<"ONLINE"<<"\n";
    }
	return 0;
}
2 Likes