In this HackerEarth Save Patients problem solution, 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.

HackerEarth Save Patients problem solution

HackerEarth Save Patients problem solution.

#include <bits/stdc++.h>

using namespace std;

int vaccine [100000 + 10];
int patient [100000 + 10];

int main()
int n;

cin >> n ;

for(int i = 0; i < n; i++) cin >> vaccine[i];
for(int i = 0; i < n; i++) cin >> patient[i];

sort(patient, patient + n);
sort(vaccine, vaccine + n);

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

if(vaccine[i] <= patient[i]){

cout << "No";
return 0;

cout << "Yes";

return 0;