# Kaalu and work [] (https://www.codechef.com/PATN2021/problems/CNTMAX1)

Practice

Author: Aryan KD
Tester: Aryan KD
Editorialist: Aryan KD

# DIFFICULTY:

CAKEWALK, SIMPLE, EASY.

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
1. //kaalu and work

2. #include<bits/stdc++.h>

3. using namespace std;

4. void testcase()

5. {

6. int n,m,k=0;

7. cin>>n>>m;

8. int a[n],b[m];

9. for(int i=0;i<n;i++){

10. cin>>a[i];

11. }

12. for(int i=0;i<m;i++){

13. cin>>b[i];

14. }

15. cin>>k;

16. int cnt1=0,cnt2=0;

17. for(int i=0;i<n;i++){

18. if(a[i]<k){

19. cnt1++;

20. }

21. }

22. for(int i=0;i<m;i++){

23. if(b[i]<k){

24. cnt2++;

25. }

26. }

27. cout<<max(cnt1,cnt2);

• }
1. int main()

2. {

3. int t;

4. cin>>t;

5. while(t–)

6. {

7. testcase();

8. cout<<endl;

9. }

10. return 0;

11. }

Tester's Solution
1. //kaalu and work

2. #include<bits/stdc++.h>

3. using namespace std;

4. void testcase()

5. {

6. int n,m,k=0;

7. cin>>n>>m;

8. int a[n],b[m];

9. for(int i=0;i<n;i++){

10. cin>>a[i];

11. }

12. for(int i=0;i<m;i++){

13. cin>>b[i];

14. }

15. cin>>k;

16. int cnt1=0,cnt2=0;

17. for(int i=0;i<n;i++){

18. if(a[i]<k){

19. cnt1++;

20. }

21. }

22. for(int i=0;i<m;i++){

23. if(b[i]<k){

24. cnt2++;

25. }

26. }

27. cout<<max(cnt1,cnt2);

• }
1. int main()

2. {

3. int t;

4. cin>>t;

5. while(t–)

6. {

7. testcase();

8. cout<<endl;

9. }

10. return 0;

11. }

Editorialist's Solution
1. //kaalu and work

2. #include<bits/stdc++.h>

3. using namespace std;

4. void testcase()

5. {

6. int n,m,k=0;

7. cin>>n>>m;

8. int a[n],b[m];

9. for(int i=0;i<n;i++){

10. cin>>a[i];

11. }

12. for(int i=0;i<m;i++){

13. cin>>b[i];

14. }

15. cin>>k;

16. int cnt1=0,cnt2=0;

17. for(int i=0;i<n;i++){

18. if(a[i]<k){

19. cnt1++;

20. }

21. }

22. for(int i=0;i<m;i++){

23. if(b[i]<k){

24. cnt2++;

25. }

26. }

27. cout<<max(cnt1,cnt2);

• }
1. int main()

2. {

3. int t;

4. cin>>t;

5. while(t–)

6. {

7. testcase();

8. cout<<endl;

9. }

10. return 0;

11. }