From 0f971271ade8f7ca4706881809b2e8e367ad07d1 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 7 Dec 2022 11:33:32 +0100 Subject: day 7 part 2, entirely from my phone --- 22.7/main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/22.7/main.cpp b/22.7/main.cpp index 66c85e8..4708419 100644 --- a/22.7/main.cpp +++ b/22.7/main.cpp @@ -1,4 +1,6 @@ +#include #include +#include #include #include #include @@ -75,9 +77,18 @@ main() } long total1 = 0; - getSizes(&root, [&](long size){ + long used = getSizes(&root, [&](long size){ if (size <= 100000) total1 += size; }); cout << total1 << endl; + + long diskSize = 70000000; + long updateSize = 30000000; + long smallest = numeric_limits::max(); + getSizes(&root, [&](long size){ + if (used - size + updateSize <= diskSize) + smallest = min(smallest, size); + }); + cout << smallest << endl; } -- cgit 1.4.1-2-gfad0