結果

問題 No.607 開通777年記念
ユーザー むらためむらため
提出日時 2019-01-18 09:01:38
言語 Nim
(2.0.2)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 750 bytes
コンパイル時間 1,848 ms
コンパイル使用メモリ 66,624 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 02:09:59
合計ジャッジ時間 2,660 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 15 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

import sequtils
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  var minus = false
  while true:
    var k = getchar_unlocked()
    if k == '-' : minus = true
    elif k < '0' or k > '9': break
    else: result = 10 * result + k.ord - '0'.ord
  if minus: result *= -1
template times*(n:int,body) = (for _ in 0..<n: body)

let n = scan()
let m = scan()
var A = newSeq[int](n)
m.times:
  var xa = -1
  var ya = -1
  for i in 0..<n:
    A[i] += scan()
    if A[i] <= 777:
      if xa < 0 : xa = i
      ya = i
  if xa < 0 : continue
  var x = xa
  var sum = 0 # [x,y]
  for y in xa..ya:
    sum += A[y]
    while sum > 777 :
      sum -= A[x]
      x += 1
    if sum == 777: quit "YES",0

echo "NO"
0