結果
問題 |
No.79 過小評価ダメ・ゼッタイ
|
ユーザー |
![]() |
提出日時 | 2024-10-07 21:13:24 |
言語 | Common Lisp (sbcl 2.5.0) |
結果 |
AC
|
実行時間 | 30 ms / 5,000 ms |
コード長 | 1,238 bytes |
コンパイル時間 | 219 ms |
コンパイル使用メモリ | 39,292 KB |
実行使用メモリ | 30,144 KB |
最終ジャッジ日時 | 2024-10-07 21:13:26 |
合計ジャッジ時間 | 1,245 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 07 OCT 2024 09:13:24 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.005
ソースコード
; 6個以上の配列を用意してカウントしていく ; メモした配列の中から最大のものうちインデックスが最大のものを答える (defun main () (let* ((n (read)) (xs (make-array 6 :initial-element 0)) (ans 1) (v 0)) (dotimes (_ n) (incf (aref xs (1- (read))))) (dotimes (i 6) (if (>= (aref xs i) v) (progn (setq ans (1+ i)) (setq v (aref xs i))))) (princ ans) (terpri))) (main) ; (defun main () ; (let* ((n (read)) ; (memo (make-array 7 :initial-element 0))) ; (dotimes (_ n) ; (let ((m (read))) ; (incf (aref memo m)))) ; ; reduce function sequence &key key from-end start end initial-value ⇒ result ; ; reduce 関数は sequence の要素を(デフォルトでは)左から function を ; ; start から end まで順次適用していく ; (let ((l (reduce #'max memo))) ; ; position item sequence &key from-end test test-not start end key => position ; ; from-end t によって難易度が高い順に最大値を調べることができる ; (princ (position l memo :from-end t)) ; (terpri))))