usaco: Add O(n) dynamic algorithm for beads in Java

Signed-off-by: Rohit Yadav <bhaisaab@baagi.org>