Author: Aryan KD
Tester: Aryan KD
Editorialist: Aryan KD
DIFFICULTY:
CAKEWALK, SIMPLE, EASY.
PREREQUISITES:
Math .
PROBLEM:
Kaalu has given work by his grandfather. he has given two array Arr1 and AArr2 of length M and N respectively .
Kaalu has given one number KK and he has to count a number of element less than Kin Arr1 and Arr2 , then he has to print the max number of count which is less than K.
QUICK EXPLANATION:
you have just given two arrays and one another number that is k and you have to find max number of count which is less than k in both the array
EXPLANATION:
you have given two arrays you have also given a number K you have just compare the K in the both the array and count the number which is less than k and in last you have to print the max number of count
SOLUTIONS:
Setter's Solution
-
//kaalu and work
-
#include<bits/stdc++.h>
-
using namespace std;
-
void testcase()
-
{
-
int n,m,k=0;
-
cin>>n>>m;
-
int a[n],b[m];
-
for(int i=0;i<n;i++){
-
cin>>a[i];
-
}
-
for(int i=0;i<m;i++){
-
cin>>b[i];
-
}
-
cin>>k;
-
int cnt1=0,cnt2=0;
-
for(int i=0;i<n;i++){
-
if(a[i]<k){
-
cnt1++;
-
}
-
}
-
for(int i=0;i<m;i++){
-
if(b[i]<k){
-
cnt2++;
-
}
-
}
-
cout<<max(cnt1,cnt2);
- }
-
int main()
-
{
-
int t;
-
cin>>t;
-
while(t–)
-
{
-
testcase();
-
cout<<endl;
-
}
-
return 0;
-
}
Tester's Solution
-
//kaalu and work
-
#include<bits/stdc++.h>
-
using namespace std;
-
void testcase()
-
{
-
int n,m,k=0;
-
cin>>n>>m;
-
int a[n],b[m];
-
for(int i=0;i<n;i++){
-
cin>>a[i];
-
}
-
for(int i=0;i<m;i++){
-
cin>>b[i];
-
}
-
cin>>k;
-
int cnt1=0,cnt2=0;
-
for(int i=0;i<n;i++){
-
if(a[i]<k){
-
cnt1++;
-
}
-
}
-
for(int i=0;i<m;i++){
-
if(b[i]<k){
-
cnt2++;
-
}
-
}
-
cout<<max(cnt1,cnt2);
- }
-
int main()
-
{
-
int t;
-
cin>>t;
-
while(t–)
-
{
-
testcase();
-
cout<<endl;
-
}
-
return 0;
-
}
Editorialist's Solution
-
//kaalu and work
-
#include<bits/stdc++.h>
-
using namespace std;
-
void testcase()
-
{
-
int n,m,k=0;
-
cin>>n>>m;
-
int a[n],b[m];
-
for(int i=0;i<n;i++){
-
cin>>a[i];
-
}
-
for(int i=0;i<m;i++){
-
cin>>b[i];
-
}
-
cin>>k;
-
int cnt1=0,cnt2=0;
-
for(int i=0;i<n;i++){
-
if(a[i]<k){
-
cnt1++;
-
}
-
}
-
for(int i=0;i<m;i++){
-
if(b[i]<k){
-
cnt2++;
-
}
-
}
-
cout<<max(cnt1,cnt2);
- }
-
int main()
-
{
-
int t;
-
cin>>t;
-
while(t–)
-
{
-
testcase();
-
cout<<endl;
-
}
-
return 0;
-
}