結果
問題 | No.1972 Modulo Set |
ユーザー | n_get |
提出日時 | 2022-07-16 16:16:19 |
言語 | Scheme (Gauche-0.9.14) |
結果 |
AC
|
実行時間 | 352 ms / 2,000 ms |
コード長 | 2,899 bytes |
コンパイル時間 | 273 ms |
コンパイル使用メモリ | 5,760 KB |
実行使用メモリ | 29,952 KB |
最終ジャッジ日時 | 2024-06-28 15:48:20 |
合計ジャッジ時間 | 7,742 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
19,712 KB |
testcase_01 | AC | 52 ms
19,712 KB |
testcase_02 | AC | 51 ms
19,456 KB |
testcase_03 | AC | 88 ms
22,272 KB |
testcase_04 | AC | 111 ms
22,400 KB |
testcase_05 | AC | 123 ms
22,912 KB |
testcase_06 | AC | 153 ms
23,168 KB |
testcase_07 | AC | 220 ms
25,856 KB |
testcase_08 | AC | 131 ms
22,784 KB |
testcase_09 | AC | 57 ms
19,968 KB |
testcase_10 | AC | 115 ms
22,656 KB |
testcase_11 | AC | 214 ms
26,112 KB |
testcase_12 | AC | 73 ms
21,376 KB |
testcase_13 | AC | 63 ms
20,480 KB |
testcase_14 | AC | 64 ms
20,736 KB |
testcase_15 | AC | 215 ms
25,344 KB |
testcase_16 | AC | 227 ms
25,216 KB |
testcase_17 | AC | 113 ms
22,656 KB |
testcase_18 | AC | 53 ms
19,456 KB |
testcase_19 | AC | 197 ms
25,900 KB |
testcase_20 | AC | 223 ms
25,208 KB |
testcase_21 | AC | 130 ms
22,912 KB |
testcase_22 | AC | 163 ms
25,088 KB |
testcase_23 | AC | 301 ms
28,800 KB |
testcase_24 | AC | 138 ms
23,424 KB |
testcase_25 | AC | 199 ms
25,600 KB |
testcase_26 | AC | 257 ms
26,112 KB |
testcase_27 | AC | 308 ms
29,568 KB |
testcase_28 | AC | 146 ms
23,552 KB |
testcase_29 | AC | 203 ms
25,856 KB |
testcase_30 | AC | 277 ms
25,216 KB |
testcase_31 | AC | 60 ms
20,352 KB |
testcase_32 | AC | 235 ms
25,472 KB |
testcase_33 | AC | 340 ms
29,952 KB |
testcase_34 | AC | 351 ms
29,904 KB |
testcase_35 | AC | 352 ms
29,696 KB |
testcase_36 | AC | 348 ms
29,936 KB |
ソースコード
(use util.queue)(use util.match)(use gauche.collection)(use gauche.sequence) (define-syntax def-syntax (syntax-rules()((_ v e ...)(define-syntax v (syntax-rules e ...))))) (define-syntax def-const define-constant)(define-syntax def define)(define-syntax def-inline define-inline) (def-syntax def-names ()((_[x y]...)(begin(define-constant x y)...))) (def-names [// quotient][% modulo][v-make make-vector][v-ref vector-ref][v-set! vector-set!][ht-make make-hash-table][ht-ref hash-table-get][ht-set! hash-table-put!][ht-keys hash-table-keys][ht-values hash-table-values][q-make make-queue][make-q make-queue][enq! enqueue!][deq! dequeue!][q-empty? queue-empty?]) (def-syntax input (: list vec cons str) ((_ : cons e ...)(cons(input : e ...)(input : e ...)))((_ : list str)(input : string->list str)) ((_ : vec str)(input : string->vector str))((_ : vec n e ...)(vector-tabulate n(^_(input : e ...)))) ((_ : list n e ...)(let l([k n])(if(zero? k)'()(cons(input : e ...)(l(- k 1))))))((_ :)(read))((_ : : e)e) ((_ : str)(let1 s(read-line)(if(string=? s "")(read-line)s)))((_[[v]: e ...])(def v(input : e ...))) ((_[[v w ...]: e ...])(begin(def v(input : e ...))(input[[w ...]: e ...]))) ((_[v : e ...])(def v(input : e ...)))((_ : op e ...)(op(input : e ...))) ((_(e ...))(e ...))((_ v)(def v(read)))((_ e ...)(begin(input e)...))) (def-syntax for [in to with] ((_[i N]e ...)(dotimes [i N] e ...)) ((_[i A to B]e ...) (let[[a A][b B]](if (< A B)(let loop[[i a]] e ... (when (< i b) (loop (+ i 1)))) (let loop[[i a]] e ... (when (> i b) (loop (- i 1))))))) ((_[[x ...]in[A ...]with i]e ...)(for-each-with-index(^(i x ...)e ...)A ...)) ((_[[x ...]in[A ...]]e ...)(for-each(^(x ...)e ...)A ...)) ((_[x in A with i]e ...)(for-each-with-index(^(i x)e ...)A)) ((_[x in A]e ...)(for-each(^(x) e ...)A)) ((_[k v in H]e ...)(hash-table-for-each H(^(k v)e ...)))) (define-constant *MOD* 1000000007) ;(define-constant *MOD* 998244353) (def-syntax add-mod! ()((_ v x)(let1 y(+ v x)(set! v(if(< y *MOD*)y(- y *MOD*)))))) (def-inline(v-add-mod! v i x)(let1 y(+(v-ref v i)x)(v-set! v i(if(< y *MOD*)y(- y *MOD*))))) (def-syntax max! ()((_ v x)(set! v (max x v)))) (def-syntax min! ()((_ v x)(set! v (min x v)))) (def-inline(v-add! v i x)(v-set! v i(+ x(v-ref v i)))) (def-inline(ht-add! ht i x)(ht-set! ht i(+ x(ht-ref ht i 0)))) (def-inline(ht-cons! ht i x)(ht-set! ht i(cons x(ht-ref ht i '())))) (def-syntax return () ((_ e ...) (begin (print e ...) (exit)))) ;; 以下スニペットのコピペ ;; 以下が本体 (input N M [A : vec N]) (def ht (make-hash-table)) (for [a in A] (ht-add! ht (mod a M) 1) (ht-add! ht (- M (mod a M)) 0)) (def ans 0) (for [a n in ht] (when (< 0 a (- M a)) (inc! ans (max n (ht-ref ht (- M a)))))) (when (even? M) (inc! ans (min 1 (ht-ref ht (ash M -1) 0)))) (inc! ans (min 1 (ht-ref ht 0 0))) (print ans)