diff --git a/usaco/Breed Counting/a.out b/usaco/Breed Counting/a.out new file mode 100755 index 0000000..2fef82b Binary files /dev/null and b/usaco/Breed Counting/a.out differ diff --git a/usaco/Breed Counting/index.cpp b/usaco/Breed Counting/index.cpp new file mode 100644 index 0000000..9b81be3 --- /dev/null +++ b/usaco/Breed Counting/index.cpp @@ -0,0 +1,34 @@ +using namespace std; + +#include +#include + +int main() { + freopen("bcount.in", "r", stdin); + freopen("bcount.out", "w", stdout); + int n, q; + cin >> n >> q; + int cow_array[n]; + for (int i = 0; i < n; i++) { + int j; + cin >> j; + cow_array[i] = j; + } + for (int i = 0; i < q; i++) { + int j, k; + cin >> j >> k; + int a = 0; + int b = 0; + int c = 0; + for (int i = 0; i < abs(j - k) + 1; i++) { + if (cow_array[i + j - 1] == 1) { + a++; + } else if (cow_array[i + j - 1] == 2) { + b++; + } else if (cow_array[i + j - 1] == 3) { + c++; + } + } + cout << a << " " << b << " " << c << endl; + } +} diff --git a/usaco/Mixing Milk/a.out b/usaco/Mixing Milk/a.out new file mode 100755 index 0000000..5a0c37d Binary files /dev/null and b/usaco/Mixing Milk/a.out differ diff --git a/usaco/Mixing Milk/index.cpp b/usaco/Mixing Milk/index.cpp new file mode 100644 index 0000000..c1b2c8b --- /dev/null +++ b/usaco/Mixing Milk/index.cpp @@ -0,0 +1,69 @@ +using namespace std; + +#include + +int main() { + freopen("mixmilk.in", "r", stdin); + freopen("mixmilk.out", "w", stdout); + + int a_cap, a_val; + cin >> a_cap >> a_val; + int b_cap, b_val; + cin >> b_cap >> b_val; + int c_cap, c_val; + cin >> c_cap >> c_val; + + for (int i = 0; i < 33; i++) { + int a_diff, b_diff, c_diff; + a_diff = abs(a_cap - a_val); + b_diff = abs(b_cap - b_val); + c_diff = abs(c_cap - c_val); + + if (b_diff >= a_val) { + b_val += a_val; + a_val = 0; + } else { + b_val = b_cap; + a_val -= b_diff; + } + a_diff = abs(a_cap - a_val); + b_diff = abs(b_cap - b_val); + c_diff = abs(c_cap - c_val); + + if (c_diff >= b_val) { + c_val += b_val; + b_val = 0; + } else { + c_val = c_cap; + b_val -= c_diff; + } + a_diff = abs(a_cap - a_val); + b_diff = abs(b_cap - b_val); + c_diff = abs(c_cap - c_val); + + if (a_diff >= c_val) { + a_val += c_val; + c_val = 0; + } else { + a_val = a_cap; + c_val -= a_diff; + } + a_diff = abs(a_cap - a_val); + b_diff = abs(b_cap - b_val); + c_diff = abs(c_cap - c_val); + } + int a_diff, b_diff, c_diff; + a_diff = abs(a_cap - a_val); + b_diff = abs(b_cap - b_val); + c_diff = abs(c_cap - c_val); + + if (b_diff >= a_val) { + b_val += a_val; + a_val = 0; + } else { + b_val = b_cap; + a_val -= b_diff; + } + + cout << a_val << endl << b_val << endl << c_val << endl; +} diff --git a/usaco/Mixing Milk/mixmilk.in b/usaco/Mixing Milk/mixmilk.in new file mode 100644 index 0000000..b74be8d --- /dev/null +++ b/usaco/Mixing Milk/mixmilk.in @@ -0,0 +1,3 @@ +10 3 +11 4 +12 5 diff --git a/usaco/Mixing Milk/mixmilk.out b/usaco/Mixing Milk/mixmilk.out new file mode 100644 index 0000000..c2a9177 --- /dev/null +++ b/usaco/Mixing Milk/mixmilk.out @@ -0,0 +1,3 @@ +0 +10 +2 diff --git a/usaco/Shell Game/a.out b/usaco/Shell Game/a.out new file mode 100755 index 0000000..3dfbf68 Binary files /dev/null and b/usaco/Shell Game/a.out differ diff --git a/usaco/Shell Game/index.cpp b/usaco/Shell Game/index.cpp new file mode 100644 index 0000000..a4db919 --- /dev/null +++ b/usaco/Shell Game/index.cpp @@ -0,0 +1,41 @@ +using namespace std; + +#include +#include + +int main() { + freopen("shell.in", "r", stdin); + freopen("shell.out", "w", stdout); + + int n; + cin >> n; + + int score = 0; + + int a_values[n]; + int b_values[n]; + int g_values[n]; + for (int i = 0; i < n; i++) { + cin >> a_values[i] >> b_values[i] >> g_values[i]; + } + int shell_num; + shell_num = 0; + for (int i = 0; i < 3; i++) { + shell_num = i + 1; + for (int j = 0; j < n; j++) { + int a, b, g; + a = a_values[i]; + b = b_values[i]; + g = g_values[i]; + if (a == shell_num) { + shell_num = b; + } else if (b == shell_num) { + shell_num = a; + } + if (g == shell_num) { + score++; + } + } + } + cout << score << endl; +} diff --git a/usaco/Shell Game/shell.out b/usaco/Shell Game/shell.out new file mode 100644 index 0000000..e69de29