結果

問題 No.607 開通777年記念
ユーザー hoktohokto
提出日時 2020-04-06 17:50:09
言語 Ruby
(3.3.0)
結果
AC  
実行時間 575 ms / 2,000 ms
コード長 1,290 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 11,352 KB
実行使用メモリ 15,652 KB
最終ジャッジ日時 2023-09-20 19:35:27
合計ジャッジ時間 3,064 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,016 KB
testcase_01 AC 77 ms
15,124 KB
testcase_02 AC 78 ms
15,120 KB
testcase_03 AC 78 ms
15,156 KB
testcase_04 AC 78 ms
15,176 KB
testcase_05 AC 78 ms
15,128 KB
testcase_06 AC 78 ms
15,124 KB
testcase_07 AC 108 ms
15,312 KB
testcase_08 AC 78 ms
15,152 KB
testcase_09 AC 90 ms
15,600 KB
testcase_10 AC 78 ms
15,084 KB
testcase_11 AC 523 ms
15,652 KB
testcase_12 AC 575 ms
15,404 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,M=get_i
train=array(N,0)
M.times do
  a=get_i
  a.each_with_index do|a_,i|
      train[i]+=a_
  end 
  tail=0
  sum=0
  flag=false
  N.times do|i|
    while tail<N and sum<777
        sum+=train[tail]
        tail+=1
    end
    break if sum<777
    if sum==777
      flag=true
      break
    end
    sum-=train[i]
  end
  if flag
      puts "YES"
      exit
  end
end
puts "NO"
0