• + 0 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 }] [])
            )
        )
    )