From 8df6bf6fdf32f7c18d0699c2efef00135a4849e0 Mon Sep 17 00:00:00 2001 From: Ta180m Date: Wed, 8 May 2019 08:35:43 -0500 Subject: Update dp_solver.cpp --- dp_solver.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dp_solver.cpp b/dp_solver.cpp index 055990c..3bbb1c2 100644 --- a/dp_solver.cpp +++ b/dp_solver.cpp @@ -66,8 +66,14 @@ int main() { // Set initial value DP[s] = start; + + // Find the optimal solution + int sol = 7200000; for (int i = 0; i < 36000 * max_it; i++) { if (DP[i] != -1) { + if (i / 36000 > sol / 36000) break; + if (DP[i] >= goal && (sol == 7200000 || DP[i] > DP[sol])) sol = i; + // Calculate parameters int it = i / 36000; int MPQ = (i / 3600) % 10, SB = (i / 360) % 10, M = (i / 36) % 10; @@ -150,13 +156,6 @@ int main() { } } - // Find the optimal solution - int sol = 7200000; - for (int i = 0; i < 36000 * max_it; i++) { - if (i / 36000 > sol / 36000) break; - if (DP[i] >= goal && (sol == 7200000 || DP[i] > DP[sol])) sol = i; - } - // Print output if (sol != 7200000) { vector output; -- cgit v1.2.3-70-g09d2