結果

問題 No.2247 01 ZigZag
ユーザー simansiman
提出日時 2023-03-18 12:55:26
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 452 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 11,896 KB
実行使用メモリ 20,096 KB
最終ジャッジ日時 2023-10-18 17:14:52
合計ジャッジ時間 8,894 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
16,112 KB
testcase_01 AC 80 ms
16,112 KB
testcase_02 AC 82 ms
16,372 KB
testcase_03 AC 120 ms
18,008 KB
testcase_04 AC 82 ms
16,112 KB
testcase_05 AC 112 ms
17,724 KB
testcase_06 AC 103 ms
17,328 KB
testcase_07 AC 82 ms
16,636 KB
testcase_08 AC 140 ms
18,452 KB
testcase_09 AC 120 ms
17,988 KB
testcase_10 AC 82 ms
16,908 KB
testcase_11 AC 113 ms
17,840 KB
testcase_12 AC 112 ms
17,716 KB
testcase_13 AC 108 ms
17,200 KB
testcase_14 AC 82 ms
16,368 KB
testcase_15 AC 115 ms
17,844 KB
testcase_16 AC 133 ms
18,392 KB
testcase_17 AC 140 ms
18,636 KB
testcase_18 AC 84 ms
16,636 KB
testcase_19 AC 83 ms
16,368 KB
testcase_20 AC 84 ms
16,112 KB
testcase_21 AC 94 ms
16,892 KB
testcase_22 AC 143 ms
19,136 KB
testcase_23 AC 101 ms
17,064 KB
testcase_24 AC 82 ms
16,372 KB
testcase_25 AC 134 ms
18,524 KB
testcase_26 AC 125 ms
18,036 KB
testcase_27 AC 123 ms
18,288 KB
testcase_28 AC 141 ms
19,080 KB
testcase_29 AC 125 ms
18,348 KB
testcase_30 AC 148 ms
19,352 KB
testcase_31 AC 86 ms
16,900 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 91 ms
16,596 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 88 ms
16,900 KB
testcase_44 AC 81 ms
16,900 KB
testcase_45 AC 164 ms
20,096 KB
testcase_46 AC 162 ms
19,708 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 82 ms
16,112 KB
testcase_50 AC 82 ms
16,112 KB
testcase_51 AC 81 ms
16,112 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:9: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

N, M, K = gets.split.map(&:to_i)

zero_stack = [0] * N
one_stack = [1] * M

max = 2 * [N, M].min

if K == 0 || max < K
  puts -1
  exit
end

k = K

if k.even?
  one_stack.push(zero_stack.pop)
  k -= 1
end

ans = []
d = (k + 1) / 2

while zero_stack.size > d
  ans << zero_stack.shift
end

while zero_stack.size > 0 || one_stack.size > 0
  ans << zero_stack.shift if zero_stack.size > 0
  ans << one_stack.shift if one_stack.size > 0
end

puts ans.join
0