結果
問題 |
No.79 過小評価ダメ・ゼッタイ
|
ユーザー |
![]() |
提出日時 | 2024-10-07 21:12:08 |
言語 | Common Lisp (sbcl 2.5.0) |
結果 |
AC
|
実行時間 | 33 ms / 5,000 ms |
コード長 | 1,245 bytes |
コンパイル時間 | 216 ms |
コンパイル使用メモリ | 33,280 KB |
実行使用メモリ | 30,140 KB |
最終ジャッジ日時 | 2024-10-07 21:12:10 |
合計ジャッジ時間 | 1,350 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 07 OCT 2024 09:12:08 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.007
ソースコード
; 6個以上の配列を用意してカウントしていく ; メモした配列の中から最大のものうちインデックスが最大のものを答える (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)))) (main) ; (defun another-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)))