結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
16,108 KB
testcase_01 AC 84 ms
16,108 KB
testcase_02 AC 83 ms
16,368 KB
testcase_03 AC 122 ms
18,004 KB
testcase_04 AC 82 ms
16,108 KB
testcase_05 AC 116 ms
17,720 KB
testcase_06 AC 105 ms
17,324 KB
testcase_07 AC 82 ms
16,632 KB
testcase_08 AC 134 ms
18,448 KB
testcase_09 AC 121 ms
17,984 KB
testcase_10 AC 83 ms
16,904 KB
testcase_11 AC 113 ms
17,836 KB
testcase_12 AC 115 ms
17,708 KB
testcase_13 AC 102 ms
17,200 KB
testcase_14 AC 85 ms
16,368 KB
testcase_15 AC 118 ms
17,840 KB
testcase_16 AC 132 ms
18,392 KB
testcase_17 AC 139 ms
18,632 KB
testcase_18 AC 82 ms
16,632 KB
testcase_19 AC 82 ms
16,368 KB
testcase_20 AC 82 ms
16,108 KB
testcase_21 AC 94 ms
16,888 KB
testcase_22 AC 143 ms
19,132 KB
testcase_23 AC 102 ms
17,060 KB
testcase_24 AC 82 ms
16,368 KB
testcase_25 AC 138 ms
18,520 KB
testcase_26 AC 122 ms
18,032 KB
testcase_27 AC 122 ms
18,284 KB
testcase_28 AC 142 ms
19,076 KB
testcase_29 AC 130 ms
18,344 KB
testcase_30 AC 148 ms
19,352 KB
testcase_31 AC 82 ms
16,892 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 93 ms
16,592 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 82 ms
16,896 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 84 ms
16,108 KB
testcase_44 AC 81 ms
16,108 KB
testcase_45 AC 166 ms
20,092 KB
testcase_46 AC 164 ms
19,708 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 83 ms
16,108 KB
testcase_50 AC 83 ms
16,108 KB
testcase_51 AC 83 ms
16,108 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:4: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:15: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

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

if (N == 0 || M == 0) && K != 0
  puts -1
  exit
end

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

max = 2 * [N, M].min
max -= 1 if N == M

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