diff options
author | Ta180m | 2019-07-17 14:30:33 -0400 |
---|---|---|
committer | GitHub | 2019-07-17 14:30:33 -0400 |
commit | 504851d486ba7655858936fbf6ed1ca0fffd8734 (patch) | |
tree | c936fad502744980fc1667823610a43838a4847c | |
parent | f5f3187bdcd7b0b796ed75d418668990e79e35e7 (diff) |
Create guard.cpp
-rw-r--r-- | 2014/December/Gold/guard.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/2014/December/Gold/guard.cpp b/2014/December/Gold/guard.cpp new file mode 100644 index 0000000..1787a44 --- /dev/null +++ b/2014/December/Gold/guard.cpp @@ -0,0 +1,21 @@ +#include <algorithm> +#include <iostream> +using namespace std; + +int h[1 << 20], 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++) { + for (int j = 0; j < N; j++) i & 1 << j ? h[i] += C[j].h : DP[i ^ 1 << j] = max(min(C[j].s, DP[i] - C[j].w), DP[i ^ 1 << j]); + } + + int ans = 0; + for (int i = 0; i < (1 << N); i++) if (h[i] >= H) ans = max(DP[i], ans); + ans != 0 ? cout << ans << endl : cout << "Mark is too tall" << endl; +} |