結果

問題 No.905 Sorted?
ユーザー simansiman
提出日時 2023-03-21 22:11:13
言語 Ruby
(3.3.0)
結果
AC  
実行時間 465 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 11,864 KB
実行使用メモリ 31,340 KB
最終ジャッジ日時 2023-10-18 18:37:44
合計ジャッジ時間 10,561 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
16,076 KB
testcase_01 AC 89 ms
16,076 KB
testcase_02 AC 87 ms
16,076 KB
testcase_03 AC 89 ms
16,076 KB
testcase_04 AC 89 ms
16,076 KB
testcase_05 AC 91 ms
16,296 KB
testcase_06 AC 90 ms
16,076 KB
testcase_07 AC 97 ms
16,616 KB
testcase_08 AC 427 ms
24,060 KB
testcase_09 AC 297 ms
23,124 KB
testcase_10 AC 390 ms
24,904 KB
testcase_11 AC 411 ms
22,528 KB
testcase_12 AC 450 ms
22,384 KB
testcase_13 AC 460 ms
31,340 KB
testcase_14 AC 465 ms
31,340 KB
testcase_15 AC 453 ms
30,308 KB
testcase_16 AC 452 ms
30,528 KB
testcase_17 AC 452 ms
30,516 KB
testcase_18 AC 372 ms
30,516 KB
testcase_19 AC 87 ms
16,076 KB
testcase_20 AC 87 ms
16,076 KB
testcase_21 AC 87 ms
16,076 KB
testcase_22 AC 87 ms
16,076 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
Q = gets.to_i

counter = Array.new(N) { [0, 0] }

1.upto(N - 1) do |i|
  counter[i][0] = counter[i - 1][0]
  counter[i][1] = counter[i - 1][1]

  if A[i - 1] < A[i]
    counter[i][0] += 1
  elsif A[i - 1] > A[i]
    counter[i][1] += 1
  end
end

Q.times do
  l, r = gets.split.map(&:to_i)
  ans = [0, 0]

  if counter[r][0] == counter[l][0]
    ans[1] = 1
  end

  if counter[r][1] == counter[l][1]
    ans[0] = 1
  end

  puts ans.join(' ')
end
0