結果
問題 | No.1767 BLUE to RED |
ユーザー | motoshira |
提出日時 | 2021-11-27 00:28:09 |
言語 | Common Lisp (sbcl 2.3.8) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,714 bytes |
コンパイル時間 | 1,304 ms |
コンパイル使用メモリ | 35,532 KB |
実行使用メモリ | 84,288 KB |
最終ジャッジ日時 | 2024-06-29 19:05:14 |
合計ジャッジ時間 | 6,284 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
26,408 KB |
testcase_01 | AC | 9 ms
26,408 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 9 ms
26,280 KB |
testcase_07 | AC | 10 ms
26,536 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 341 ms
78,212 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 29 JUN 2024 07:05:06 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.109
ソースコード
(in-package #:cl-user) ;;------------------------------Preferences------------------------------ (eval-when (:compile-toplevel :load-toplevel :execute) #+swank (declaim (optimize (speed 3) (safety 2))) #-swank (declaim (optimize (speed 3) (safety 0) (debug 0))) #+swank (load "~/ghq/github.com/motoshira/atcoder-submission/ac-tools/act.lisp") #+swank (ql:quickload :prove) #-swank (declaim (sb-ext:muffle-conditions sb-ext:compiler-note)) #-swank (sb-ext:disable-debugger) (pushnew :inline-generic-funcion *features*)) ;;---------------------------------Body--------------------------------- (in-package #:cl-user) (declaim (inline println)) (defun println (obj &optional (stream *standard-output*)) (let ((*read-default-float-format* 'double-float)) (prog1 obj (princ obj stream) (terpri stream)))) (defun read-into (count &optional (result-type 'list) (reader #'read)) (coerce (loop :repeat count :collect (funcall reader)) result-type)) (defconstant +inf+ #.(ash 1 60)) (defun main () (let* ((n (read)) (m (read)) (as (read-into n)) (bs (read-into m)) (es nil)) ;; blue -> 0 ;; red -> 1 (dolist (a as) (push (list a 1) es)) (push (list +inf+ 1) es) (push (list -1 1) es) (dolist (b bs) (push (list b 0) es)) (setf es (sort es #'< :key #'first)) (let ((res 0) (cs nil) (a nil)) (flet ((push-blue! (blue) (push blue cs)) (inc-and-flush-blue! (red) (declare (fixnum red)) (when (and a (< red +inf+)) (incf res (- (abs (- red a)) (loop :for (b0 b1) :on (concatenate 'list (list a) (reverse cs) (list red)) :by #'cdr :when b1 :maximize (abs (- b0 b1)))))) (setf a red cs nil))) (loop :for (value type) :in es :do (ecase type (0 (push-blue! value)) (1 (inc-and-flush-blue! value)))) (println res))))) #-swank (main) #+swank (defun run () (let ((*standard-input* (make-string-input-stream (with-output-to-string (*standard-output*) (run-program (merge-pathnames "copy-or-paste" (truename "~/bin/")) '() :output *standard-output*))))) (main)))