summary refs log tree commit diff
path: root/22.7/main.cpp
diff options
context:
space:
mode:
authordzwdz2022-12-07 11:33:32 +0100
committerdzwdz2022-12-07 11:33:32 +0100
commit0f971271ade8f7ca4706881809b2e8e367ad07d1 (patch)
tree33a62052bce0a38ee715ce9595eddb2d926c0c04 /22.7/main.cpp
parent158c2e5dffe0e7ae24e9d93addb74b4bba12531b (diff)
day 7 part 2, entirely from my phone
Diffstat (limited to '22.7/main.cpp')
-rw-r--r--22.7/main.cpp13
1 files changed, 12 insertions, 1 deletions
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 <algorithm>
 #include <iostream>
+#include <limits>
 #include <string>
 #include <unordered_map>
 #include <vector>
@@ -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<long>::max();
+	getSizes(&root, [&](long size){
+			if (used - size + updateSize <= diskSize)
+				smallest = min(smallest, size);
+	});
+	cout << smallest << endl;
 }