結果

問題 No.647 明太子
ユーザー ducktailducktail
提出日時 2018-03-01 15:26:11
言語 Scheme
(Gauche-0.9.15)
結果
AC  
実行時間 1,219 ms / 4,500 ms
コード長 1,322 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 7,196 KB
実行使用メモリ 18,432 KB
最終ジャッジ日時 2024-06-27 02:46:59
合計ジャッジ時間 6,073 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (main args)
  (let* [(n (read))
         (vab (vector-tabulate n (^_ (let* [(x (read))
                                            (y (read))]
                                       (cons x y)))))
         (m (read))
         (vxy (vector-tabulate m (^_ (let* [(a (read))
                                            (b (read))]
                                       (cons a b)))))
         (vc (make-vector m 0))]
    (let loop [(i 0)
               (j 0)]
      (cond [(= i n) #t]
            [(= j m) (loop (+ i 1) 0)]
            [else
      (let [(a (car (vector-ref vab i)))
            (b (cdr (vector-ref vab i)))
            (x (car (vector-ref vxy j)))
            (y (cdr (vector-ref vxy j)))]
        (cond [(and (>= a x) (<= b y)) (vector-set! vc j (+ 1 (vector-ref vc j)))])
        (loop i (+ j 1)))]))
    (for-each print
              (let loop [(i 0)
                         (mx 0)
                         (ls '())]
                (cond [(= i m) (if (null? ls) '(0) (reverse ls))]
                      [(zero? (vector-ref vc i)) (loop (+ i 1) mx ls)]
                      [(> (vector-ref vc i) mx) (loop (+ i 1) (vector-ref vc i) (list (+ i 1)))]
                      [(= (vector-ref vc i) mx) (loop (+ i 1) mx (cons (+ i 1) ls))]
                      [else (loop (+ i 1) mx ls)]))))
  0)
0