結果

問題 No.241 出席番号(1)
ユーザー kazasikikazasiki
提出日時 2015-07-28 09:58:45
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 11,244 KB
実行使用メモリ 19,508 KB
最終ジャッジ日時 2023-09-23 04:34:02
合計ジャッジ時間 6,047 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
19,508 KB
testcase_01 AC 80 ms
15,060 KB
testcase_02 AC 81 ms
15,264 KB
testcase_03 AC 80 ms
15,264 KB
testcase_04 AC 80 ms
15,128 KB
testcase_05 WA -
testcase_06 AC 80 ms
15,312 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 80 ms
15,252 KB
testcase_10 AC 80 ms
15,396 KB
testcase_11 AC 82 ms
15,360 KB
testcase_12 AC 81 ms
15,400 KB
testcase_13 AC 80 ms
15,252 KB
testcase_14 AC 84 ms
15,268 KB
testcase_15 AC 81 ms
15,132 KB
testcase_16 AC 80 ms
15,284 KB
testcase_17 WA -
testcase_18 AC 81 ms
15,288 KB
testcase_19 AC 80 ms
15,340 KB
testcase_20 AC 81 ms
15,264 KB
testcase_21 AC 80 ms
15,400 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:29: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

# input
N = gets.to_i
A = N.times.map{
      gets.to_i
    }

def generate_nums size
  (0...size).map{|i| rand(0...(size-i))}
end

def dec_nums nums
  array = (0...nums.size).to_a
  nums.map{|i| array.delete_at(i)}
end

def check_nums nums
  nums.each.with_index{|num, i|
    return i if nums[i] == A[i]
  }
  return nil
end

def change_nums nums, index
  nums[index] = rand(0...(nums.size - index))
  nums
end

if A.uniq.size == 1
  p -1
else
  nums = generate_nums N
  while (ng = check_nums(dec_nums(nums))) != nil
    change_nums nums, ng
  end
  dec_nums(nums).each{|i| p i }
end
0