Thursday, 9 February 2017

Angry Professor



#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

Angry Professor 


A Discrete Mathematics professor has a class of  students. Frustrated with their lack of discipline, he decides to cancel class if fewer than  students are present when class starts.
Given the arrival time of each student, determine if the class is canceled.

Solution---
int main() {

   int t,n,k,a,r,j;
    scanf("%d",&t);
    int i;
    for(i=0;i<t;i++)
        {r=0;
        scanf("%d%d",&n,&k);
        for(j=0;j<n;j++){
       
           scanf("%d",&a);
            if(a<=0){
                r++;}
             
        }
   
        if(r>=k)
            printf("NO");
        else
            printf("YES");
        printf("\n");
    }
   
    return 0;
}

No comments:

Post a Comment