-
Notifications
You must be signed in to change notification settings - Fork 0
/
squarePeg.cc
77 lines (50 loc) · 1.24 KB
/
squarePeg.cc
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
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int power(int base, int power) {
if(power == 0) return 1;
if(power == 1) return base;
return base * power(base, power-1);
}
void setVectors(int N, int M, int K, vector<int>& plots, vector<int>& houses)
{
int plot_radius, side_length;
for(int i = 0; i < N; i++)
{
cin >> plot_radius;
plots.push_back(plot_radius);
}
for(int i = 0; i < M; i++)
{
cin >> plot_radius;
houses.push_back(plot_radius);
}
for(int i = 0; i < K; i++)
{
cin >> side_length;
int square_radius = (sqrt(power(side_length, 2) + power(side_length, 2))/2);
houses.push_back(square_radius);
}
sort(plots.begin(), plots.end());
sort(houses.begin(), houses.end());
}
int main() {
// declaring house related variables:
int N, M, K;
// declaring loop related variables:
int iters;
int plots_to_fill = 0;
// declaring house related vectors;
vector<int> plots;
vector<int> houses;
cin >> N >> M >> K;
setVectors(N, M, K, plots, houses);
iters = (N <= (M + K) ? N: (M + K));
for(int i = 0; i < iters; i++)
{
plots_to_fill += (houses[i] < plots[i]);
}
cout << plots_to_fill << endl;
}