# Question 6: Airport authority # Airport authority

In this article we will see InfyTQ Sample Coding question. You will find solution of InfyTQ Coding question in different programming language on this page.

## Problem Statement -:

In an airport , the Airport  authority decides to charge some minimum amount to the passengers who are carrying luggage with them. They set a threshold weight value, say T, if the luggage exceeds the weight threshold you should pay double the base amount. If it is less than or equal to threshold then you have to pay \$1.

## Function Description:

Complete the weight Machine function in the editor below. It has the following parameter(s):

Parameters:

 Name Type Description N Integer number of luggage T Integer weight of each luggage weights[ ] Integer array threshold weight

### Returns:

The function must return an INTEGER denoting the required amount to be paid.

## Constraints:

• 1 <= N <= 10^5
• 1 <= weights[i] <= 10^5
• 1 <= T <= 10^5

## Input Format for Custom Testing:

• The first line contains an integer, N, denoting the number of luggage’s.
• Each line i of the N subsequent lines (where 0 <= i <n) contains an integer describing weight of ith luggage.
• The next line contains an integer, T, denoting the threshold weight of the boundary wall.

## Sample Cases:

4
1
2
3
4
3

5
• ### Explanation:

Here all weights are less than threshold weight except the luggage with weight 4 (at index 3) so all pays base fare and it pays double fare.
`def weightMachine(N,weights,T):    amount=0    for i in weights:        amount+=1         if(i>T):            amount+=1     return amountN=int(input())weights=[]for i in range(N):    weights.append(int(input()))T=int(input())print(weightMachine(N,weights,T))`
`#include <stdio.h>long int weightMachine(long int N,long int weights[],long int T){    long int amount=0,i;    for(i=0;i<N;i++)    {        amount++;        if(weights[i]>T)        {            amount++;        }    }    return amount;}int main(){    long int N,i,T;    scanf("%ld",&N);    long int weights[N];    for(i=0;i<N;i++)    {        scanf("%ld",&weights[i]);    }    scanf("%ld",&T);    printf("%ld",weightMachine(N,weights,T));    return 0;}`
`#include <bits/stdc++.h>using namespace std;long int weightMachine(long int N,long int weights[],long int T){    long int amount=0,i;    for(i=0;i<N;i++)    {        amount++;        if(weights[i]>T)        {            amount++;        }    }    return amount;}int main(){    long int N,i,T;    cin>>N;        long int weights[N];    for(i=0;i<N;i++)    {        cin>>weights[i];    }    cin>>T;    cout<<weightMachine(N,weights,T);    return 0;}`
`import java.util.*;class Main{  static int weightMachine (int N, int weights[],int T)  {    int amount = 0, i;    for (i = 0; i < N; i++)    {	   amount++;	   if (weights[i] > T)	   {	      amount++;	    }    }    return amount;  }  public static void main (String[]args)  {    Scanner sc = new Scanner (System.in);    int n = sc.nextInt ();    int weights[]= new int[n];        for(int i=0; i<n; i++)      weights[i] = sc.nextInt();        int t = sc.nextInt ();          System.out.println (weightMachine(n, weights, t));          }}`