Save Patients

QUESTION

A new deadly virus has infected large population of a planet. A brilliant scientist has discovered a new strain of virus which can cure this disease. Vaccine produced from this virus has various strength depending on midichlorians count. A person is cured only if midichlorians count in vaccine batch is more than midichlorians count of person. A doctor receives a new set of report which contains midichlorians count of each infected patient, Practo stores all vaccine doctor has and their midichlorians count. You need to determine if doctor can save all patients with the vaccines he has. The number of vaccines and patients are equal.\n\nInput Format\n\nFirst line contains the number of vaccines – N. Second line contains N integers, which are strength of vaccines. Third line contains N integers, which are midichlorians count of patients.\n\nOutput Format\n\nPrint a single line containing Yes or No.\n\nInput Constraint\n\n1<N<10\nStrength of vaccines and midichlorians count of patients fit in integer.\n\nExplanation\nIf all the patients can be cured then the output is Yes and if even one patient cannot be cured then the Output is No.

“TESTCASE_1”: “5\n123 146 454 542 456\n100 328 248 689 200\n###—###SEPERATOR—###—\nNo”, “TESTCASE_2”: “5\n10 61 55 88 17\n15 76 21 73 19\n###—###SEPERATOR—###—\nNo”, “TESTCASE_3”: “5\n231 45 112 32 12\n34 25 11 105 215\n###—###SEPERATOR—###—\nYes”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

#include<stdio.h>
int main()
{
   int i,j,k,x[1000],y[1000],t,t1;
   scanf("%d\n",&i);
   for(j=0;j<i;j++)
   {
       scanf("%d",&x[j]); 
       for(j=0;j<i;j++)
         if(x[j]<x[j+1]) 
         {
            t=x[j];
            x[j]=x[j+1];
            x[j+1]=t; 
         }
    }
    for(k=0;k<i;k++)
    {
        scanf("%d",&y[k]);
        for(k=0;k<i;k++)
            if(y[k]<y[k+1])
            {
                t1=y[k];
                y[k]=y[k+1];
                y[k+1]=t1;
            }
    }
    if(y[0]>x[0])
        printf("No");
    else
        printf("Yes");
    return 0;    
}
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.