summary refs log tree commit diff
diff options
context:
space:
mode:
-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;
 }