diff options
author | Ta180m | 2019-05-08 08:35:43 -0500 |
---|---|---|
committer | GitHub | 2019-05-08 08:35:43 -0500 |
commit | 8df6bf6fdf32f7c18d0699c2efef00135a4849e0 (patch) | |
tree | ed5acad666036b692d9a2735227323766d33e7e1 | |
parent | 4bddc7048fa0d62d80c6495ac329dc61107c5ed1 (diff) |
Update dp_solver.cpp
-rw-r--r-- | dp_solver.cpp | 13 |
1 files 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<int> output; |