結果
問題 |
No.1425 Yet Another Cyclic Shifts Sorting
|
ユーザー |
![]() |
提出日時 | 2021-03-18 05:02:32 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 300 bytes |
コンパイル時間 | 332 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 43,776 KB |
最終ジャッジ日時 | 2024-11-15 22:56:32 |
合計ジャッジ時間 | 14,140 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 39 |
コンパイルメッセージ
Syntax OK
ソースコード
N = gets.to_i A = gets.split.map(&:to_i) B = A.sort.reverse P = Hash.new { |h, k| h[k] = [] } d = 0 ans = 0 A.each_with_index do |a, i| P[a] << i end B.each_with_index do |b, i| idx = (P[b].pop - d) % (N - i + 1) col = N - i - 1 next if idx == col d += idx + 1 ans += 1 end puts ans