You are viewing a single comment's thread. Return to all comments →
Got pretty close, think the algorithm is correct, I think I just need to make some optimizations to the stuff i'm caching / rechecking:
(let [line1 (read-line)] (let [fences (map read-string (clojure.string/split (read-line) #" "))] (println ((fn[x cache stopped-cache] (if (= x (count fences)) (apply max (map (fn[x] (x :valu)) (into cache stopped-cache))) (let [fence (nth fences x)] (recur (+ 1 x) (conj (map (fn[x] (let [m (min (x :mini) fence) newWidth (+ 1 (x :width)) newValu (* newWidth m)] {:valu newValu :mini m :width newWidth} ) ) cache) {:valu fence :mini fence :width 1}) (into stopped-cache cache) ) ) ) ) 0 [{:valu 0 :mini Integer/MAX_VALUE :width 0 }] []) ) ) )
Seems like cookies are disabled on this browser, please enable them to open this website
John and Fences
You are viewing a single comment's thread. Return to all comments →
Got pretty close, think the algorithm is correct, I think I just need to make some optimizations to the stuff i'm caching / rechecking: