結果

問題 No.607 開通777年記念
ユーザー ducktailducktail
提出日時 2017-12-28 22:19:13
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 1,707 ms / 2,000 ms
コード長 639 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 5,300 KB
実行使用メモリ 15,464 KB
最終ジャッジ日時 2023-08-23 08:14:27
合計ジャッジ時間 4,945 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
12,384 KB
testcase_01 AC 24 ms
12,148 KB
testcase_02 AC 24 ms
12,340 KB
testcase_03 AC 24 ms
12,236 KB
testcase_04 AC 23 ms
12,244 KB
testcase_05 AC 24 ms
12,156 KB
testcase_06 AC 23 ms
12,360 KB
testcase_07 AC 148 ms
15,368 KB
testcase_08 AC 24 ms
12,264 KB
testcase_09 AC 41 ms
14,356 KB
testcase_10 AC 23 ms
12,272 KB
testcase_11 AC 1,561 ms
15,464 KB
testcase_12 AC 1,707 ms
15,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (three-seven? n v)
  (let loop ([c 0]
             [l 0]
             [r 0])
    (cond [(= c 777) #t]
          [(> c 777) (loop (- c (vector-ref v l)) (+ l 1) r)]
          [(and (< c 777) (= r n)) #f]
          [else (loop (+ c (vector-ref v r)) l (+ r 1))])))

(define (main args)
  (let* ([n (read)]
         [m (read)])
    (print
     (let loop ([x m]
                [v (make-vector n 0)])
       (cond [(zero? x) "NO"]
             [else (let* ([av (vector-tabulate n (lambda (_) (read)))]
                          [nv (vector-map + v av)])
                     (if (three-seven? n nv) "YES" (loop (- x 1) nv)))]))))
  0)
0