-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproblem57.cpp
More file actions
67 lines (54 loc) · 1.28 KB
/
problem57.cpp
File metadata and controls
67 lines (54 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <algorithm>
using namespace std;
class InputHandler{
public:
int n;
int *vaccines;
int *patients;
InputHandler() : n(0), vaccines(nullptr), patients(nullptr) {}
void getInput(){
cout << "Enter the no of vaccines (and patients): ";
cin >> n;
vaccines = new int[n];
patients = new int[n];
cout << "Enter the midichlorians count of each vaccine batch: ";
for (int i = 0; i < n; i++)
cin >> vaccines[i];
cout << "Enter the midichlorians count for each patient: ";
for (int i = 0; i < n; i++)
cin >> patients[i];
}
~InputHandler(){
delete[] vaccines;
delete[] patients;
}
};
class CureChecker{
public:
static bool canCureAll(int *vaccines, int *patients, int n){
sort(vaccines, vaccines + n);
sort(patients, patients + n);
for (int i = 0; i < n; i++){
if (vaccines[i] <= patients[i])
return false;
}
return true;
}
};
class OutputHandler{
public:
static void printResult(bool result){
if (result)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
};
int main(){
InputHandler input;
input.getInput();
bool result = CureChecker::canCureAll(input.vaccines, input.patients, input.n);
OutputHandler::printResult(result);
return 0;
}