--- id: sp-neg title: "Shortest Paths with Negative Edge Weights" author: Benjamin Qi prerequisites: - Gold - Shortest Paths with Non-Negative Edge Weights description: Applications of Bellman-Ford. frequency: 0 --- import { Problem } from "../models"; export const metadata = { problems: { sam: [ new Problem("Kattis", "SSSP Negative", "shortestpath3", "Easy", false, [], ""), new Problem("Kattis", "APSP (with negative weights)", "allpairspath", "Easy", false, [], ""), new Problem("CSES", "(Negative) Cycle Finding", "1197", "Easy", false, [], ""), ], probs: [ new Problem("SPOJ", "Arbitrage", "ARBITRAG", "Easy", false, [], ""), new Problem("CSES", "High Score", "1673", "Easy", false, [], ""), ], linear: [ new Problem("ojuz", "Restore Array", "RMI19_restore", "Normal", false, [], "similar to [Art](https://codeforces.com/gym/102394/problem/A)"), ], } };
### Tutorial Can also use [Shortest Path Faster Algorithm](https://en.wikipedia.org/wiki/Shortest_Path_Faster_Algorithm) or modify Dijkstra slightly (though the same running time bound no longer applies). (code)? ### Problems ## Simple Linear Programming You can also use shortest path algorithms to solve the following problem (a very simple [linear program](https://en.wikipedia.org/wiki/Linear_programming)). > Given variables $x_1,x_2,\ldots,x_N$ with constraints in the form $x_i-x_j\ge c$, compute a feasible solution. Linear Programming Trick **Example:** Timeline (USACO Camp) - equivalent to [Timeline (Gold)](http://www.usaco.org/index.php?page=viewproblem2&cpid=1017) except $N,C\le 5000$ and negative values of $x$ are possible. ### Problems