Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
“You won’t get caught if you hide behind someone.”
Sang-Woo advises Gi-Hun to hide behind someone to avoid getting shot.
Gi-Hun follows Sang-Woo’s advice and hides behind Ali, who saved his life earlier. Gi-Hun and Ali both have the same height, K. Many players saw this trick and also started hiding behind Ali.
Now, there are N players standing between Gi-Hun and Ali in a straight line, with the i^th player having height Hi. Gi-Hun wants to know the minimum number of players who need to get shot so that Ali is visible in his line of sight.
Note:
For each test case, output in a single line the minimum number of players who need to get shot so that Ali is visible in Gi-Hun’s line of sight.
Input:
3
4 10
2 13 4 16
5 8
9 3 8 8 4
4 6
1 2 3 4
Output:
2
1
0
Test Case 1: Gi-Hun and Ali have height 10. For Ali to be visible to Gi-Hun, the second person (with height 13) and the fourth person (with height 16) need to get shot. Hence, the minimum number of players who need to get shot is 2.
Test Case 2: Gi-Hun and Ali have height 8. For Ali to be visible to Gi-Hun, the first person (with height 9) needs to get shot. Hence, the minimum number of players who need to get shot is 1.
Test Case 3: Nobody needs to get shot because everyone is shorter than Gi-Hun and Ali.
# cook your dish here
case = int(input())
for i in range(case):
x,y = input().split()
num = 0
l = list(map(int,input().split()))
for i in l:
if i > int(y):
num += 1
print(num)
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int n,k,count=0;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
if(a[i]>k)count++;
}
cout<<count<<endl;
}
return 0;
}
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner s= new Scanner(System.in);
int T= s.nextInt();
for(int j=0;j<T;j++){
int a= s.nextInt();
int b= s.nextInt();
int[] c= new int[a];
int m=0;
for(int i=0;i<a;i++){
c[i]=s.nextInt();
}
for(int i=0;i<a;i++){
if(c[i]>b){
m++;
}
}
System.out.println(m);
}
}
}
In our experience, we suggest you solve this Red Light, Green Light CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Red Light, Green Light CodeChef Solution
I hope this Red Light, Green Light CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>