結果
問題 |
No.343 手抜き工事のプロ
|
ユーザー |
|
提出日時 | 2016-02-13 00:19:50 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 518 bytes |
コンパイル時間 | 39 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 19,740 KB |
最終ジャッジ日時 | 2024-09-22 05:09:30 |
合計ジャッジ時間 | 4,939 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 TLE * 1 -- * 13 |
コンパイルメッセージ
Main.rb:20: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:13: warning: assigned but unused variable - ws Syntax OK
ソースコード
# 時間がないのでコミット n = gets.to_i l = gets.to_i if n == 1 then puts 0 exit end xs = $stdin.read.split.map(&:to_i).reverse xs << 0 ws = Hash.new{0} ans = 0 sum = 0 cnt = 0 for i in 0...xs.size do if i > 0 then if (xs[i-1] - xs[i]).abs >= l then puts -1 exit end j = sum / cnt.to_f + 0.5 ok = (xs[i-1] < j) && (j < xs[i-1] + l) && (xs[i] < j) && (j < xs[i] + l) ans += 1 unless ok end l.times do |o| sum += xs[i] + o cnt += 1 end end puts ans