Created
April 11, 2013 03:07
-
-
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)
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
| #!/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