結果

問題 No.397 NO MORE KADOMATSU
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2020-02-20 16:40:13
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 297 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 11,312 KB
実行使用メモリ 31,480 KB
平均クエリ数 26.22
最終ジャッジ日時 2023-09-23 19:43:04
合計ジャッジ時間 4,972 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
31,104 KB
testcase_01 AC 100 ms
31,056 KB
testcase_02 AC 106 ms
31,056 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 101 ms
31,132 KB
testcase_10 AC 101 ms
30,908 KB
testcase_11 AC 103 ms
31,184 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 98 ms
31,272 KB
testcase_17 AC 105 ms
31,092 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
O = (0 ... N).sort_by{|i| A[i] }
used = Array.new(N)
T = N.times.map do |i| 
  if O[i] != i && A[O[i]] != A[i] && !used[i] 
    used[i] = used[O[i]] = true
    "#{i} #{O[i]}"
  else
    nil
  end
end
T.compact!
puts T.size
puts T
$stdout.flush
gets
exit(0)
0