Last active
March 25, 2016 17:41
-
-
Save chrisguitarguy/40505541aed567407d09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (require '[clojure.string :as string]) | |
| (defn- str->int [s] | |
| (Integer/parseInt s)) | |
| (defn- split-spaces [s] | |
| (string/split s #"\s+")) | |
| (defn- read-test-case [] | |
| (let [[students threshold] (split-spaces (read-line)) | |
| arrivals (split-spaces (read-line))] | |
| {:students (str->int students) | |
| :threshold (str->int threshold) | |
| :arrivals (map str->int arrivals)})) | |
| (defn- students-at-start [test-case] | |
| (count (filter #(<= % 0) (:arrivals test-case)))) | |
| (defn- class-canceled? [test-case] | |
| (< (students-at-start test-case) (:threshold test-case))) | |
| (defn -main [& args] | |
| (let [tc-count (str->int (read-line)) | |
| test-cases (repeatedly tc-count read-test-case)] | |
| (doseq [test-case test-cases] | |
| (println (if (class-canceled? test-case) "YES" "NO"))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment