Skip to content

Instantly share code, notes, and snippets.

@Denommus
Created April 11, 2013 03:07
Show Gist options
  • Select an option

  • Save Denommus/5360413 to your computer and use it in GitHub Desktop.

Select an option

Save Denommus/5360413 to your computer and use it in GitHub Desktop.
Solution for the Code Jam's problem Minimum Scalar Product (https://code.google.com/codejam/contest/32016/dashboard#s=p0)
#!/usr/bin/sbcl --script
(with-open-file (in (car (last *posix-argv*)))
(let ((total-cases (read in)))
(with-open-file (out "A.out" :direction :output :if-exists :supersede)
(loop for i from 1 to total-cases do
(let* ((n (read in))
(v1 (loop for j from 0 below n collect (read in)))
(v2 (loop for j from 0 below n collect (read in))))
(format out "Case #~D: ~D~%" i
(reduce #'+ (map 'list #'* (sort v1 #'>) (sort v2 #'<)))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment