/* Contains both the fast reference solution (prepare()+eval()), and a slow recursive solution (solve()) for validation. */ import java.io.*; import java.util.*; import java.util.regex.*; import java.lang.reflect.Array; public class Spill { int n; double[] alt; double start; HashMap hm; double eps = 1e-9; boolean oldval; TreeMap tm = new TreeMap(); boolean eval(double val) { Object key = new Double(val+eps); SortedMap sm = tm.tailMap(key); boolean svar = sm.isEmpty()?oldval:((Boolean)sm.get(sm.firstKey())).booleanValue(); //ut.println(val+" eval " +svar+(sm.isEmpty()?" empty":"")); return svar; } void add(double lim, boolean val) { // ut.println("added "+lim+" " +val); tm.put(new Double(lim),Boolean.valueOf(val)); } TreeSet pot = new TreeSet(); void prepare(double max) { long tid = System.currentTimeMillis(); for (int i=0; imax) break; pot.remove(key); if (lim-oldlimoo.ind[i]) return 1; } return 0; } public static Index get(int a, int b) {return new Index(new int[]{a,b});} } /* for (Iterator it=tm.entrySet().iterator(); it.hasNext(); ) { Map.Entry me = (Map.Entry)it.next(); ut.println(me); } boolean eval(double val) { Object key = new Double(val); SortedMap sm = tm.tailMap(key); if (sm.isEmpty()) { boolean ans = false; for (int i=0; !ans && i