diff options
author | Anthony Wang | 2022-03-15 20:38:51 -0500 |
---|---|---|
committer | Anthony Wang | 2022-03-15 20:38:51 -0500 |
commit | 896c6ceeff605c935a5538e3d9eca40ea3c79c56 (patch) | |
tree | 69d97b50f5ced801f6043cbef0219a941239f892 /14.5 | |
parent | 4c488e4c73f2d0e2b96bf0c444c05d42e566dd11 (diff) |
Restructure directories AGAIN so contests from the same season are in the same directory
Diffstat (limited to '14.5')
-rw-r--r-- | 14.5/dec/gold/guard.cpp | 17 | ||||
-rw-r--r-- | 14.5/open/gold/googol.py | 12 |
2 files changed, 29 insertions, 0 deletions
diff --git a/14.5/dec/gold/guard.cpp b/14.5/dec/gold/guard.cpp new file mode 100644 index 0000000..f1c83c8 --- /dev/null +++ b/14.5/dec/gold/guard.cpp @@ -0,0 +1,17 @@ +#include <algorithm> +#include <iostream> +using namespace std; + +int ans = 0, DP[1 << 20] = { (int)1e9 }; +struct cow { int h, w, s; } C[20]; + +int main() { + int N, H; cin >> N >> H; + for (int i = 0; i < N; i++) cin >> C[i].h >> C[i].w >> C[i].s; + for (int i = 0; i < (1 << N); i++) { + int h = 0; + for (int j = 0; j < N; j++) i & 1 << j ? h += C[j].h : DP[i ^ 1 << j] = max(min(C[j].s, DP[i] - C[j].w), DP[i ^ 1 << j]); + if (h >= H) ans = max(DP[i], ans); + } + ans != 0 ? cout << ans << endl : cout << "Mark is too tall" << endl; +} diff --git a/14.5/open/gold/googol.py b/14.5/open/gold/googol.py new file mode 100644 index 0000000..5eeb3be --- /dev/null +++ b/14.5/open/gold/googol.py @@ -0,0 +1,12 @@ +def solve(u, d): + print(u) + a, b = map(int, input().split()) + if b == 0: + return (a > 0) + 1 + if d == -1: + d = 2 * solve(a, -1) + 1 + d = d - 1 + return (d >> 1) + solve(a if d % 2 == 1 else b, (d >> 1) + (d % 2)) + 1 + +ans = solve(1, -1); +print("Answer", ans); |