結果

問題 No.360 増加門松列
ユーザー neko_the_shadowneko_the_shadow
提出日時 2016-11-28 00:40:50
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 5,380 KB
実行使用メモリ 15,540 KB
最終ジャッジ日時 2023-08-25 18:40:58
合計ジャッジ時間 2,808 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
15,456 KB
testcase_01 AC 46 ms
15,512 KB
testcase_02 AC 43 ms
15,048 KB
testcase_03 AC 41 ms
14,900 KB
testcase_04 AC 44 ms
15,324 KB
testcase_05 AC 42 ms
15,180 KB
testcase_06 AC 44 ms
15,328 KB
testcase_07 AC 44 ms
15,380 KB
testcase_08 AC 44 ms
15,264 KB
testcase_09 AC 43 ms
15,124 KB
testcase_10 AC 41 ms
15,020 KB
testcase_11 AC 40 ms
15,048 KB
testcase_12 AC 44 ms
15,388 KB
testcase_13 AC 40 ms
14,888 KB
testcase_14 AC 41 ms
14,848 KB
testcase_15 AC 42 ms
15,080 KB
testcase_16 AC 40 ms
14,912 KB
testcase_17 AC 41 ms
15,056 KB
testcase_18 AC 44 ms
15,300 KB
testcase_19 AC 43 ms
15,540 KB
testcase_20 AC 41 ms
15,176 KB
testcase_21 AC 44 ms
15,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(use util.combinations)

(define (kadomatsu? x y z)
  (and (not (= x y))
       (not (= y z))
       (not (= z x))
       (< x z)
       (or (= y (min x y z))
           (= y (max x y z)))))

(define (increasing-kadomatsu? numbers)
  (let loop ((ls numbers))
    (if (< (length ls) 3)
      #t
      (if (apply kadomatsu? (take ls 3))
        (loop (cdr ls))
        #f))))

(define (MAIN)
    (let loop ((numbers-list (permutations (map string->number (string-split (read-line) #\space)))))
      (if (null? numbers-list)
        "NO"
        (if (increasing-kadomatsu? (car numbers-list))
          "YES"
          (loop (cdr numbers-list))))))
 
 (print (MAIN))
0