結果

問題 No.318 学学学学学
ユーザー 小指が強い人小指が強い人
提出日時 2015-12-11 00:55:30
言語 Ruby
(3.2.2)
結果
AC  
実行時間 661 ms / 2,000 ms
コード長 978 bytes
コンパイル時間 606 ms
コンパイル使用メモリ 11,352 KB
実行使用メモリ 43,772 KB
最終ジャッジ日時 2023-09-04 16:59:02
合計ジャッジ時間 11,798 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
17,240 KB
testcase_01 AC 123 ms
19,048 KB
testcase_02 AC 186 ms
21,176 KB
testcase_03 AC 116 ms
18,328 KB
testcase_04 AC 168 ms
20,808 KB
testcase_05 AC 661 ms
43,760 KB
testcase_06 AC 487 ms
40,452 KB
testcase_07 AC 437 ms
39,872 KB
testcase_08 AC 391 ms
39,276 KB
testcase_09 AC 341 ms
38,660 KB
testcase_10 AC 316 ms
38,156 KB
testcase_11 AC 651 ms
43,772 KB
testcase_12 AC 506 ms
40,496 KB
testcase_13 AC 450 ms
39,864 KB
testcase_14 AC 400 ms
38,956 KB
testcase_15 AC 364 ms
38,604 KB
testcase_16 AC 320 ms
38,392 KB
testcase_17 AC 429 ms
40,704 KB
testcase_18 AC 428 ms
40,224 KB
testcase_19 AC 421 ms
40,732 KB
testcase_20 AC 311 ms
37,756 KB
testcase_21 AC 81 ms
15,148 KB
testcase_22 AC 81 ms
15,304 KB
testcase_23 AC 81 ms
15,300 KB
testcase_24 AC 81 ms
15,140 KB
testcase_25 AC 81 ms
15,280 KB
testcase_26 AC 82 ms
15,332 KB
testcase_27 AC 82 ms
15,284 KB
testcase_28 AC 81 ms
15,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

map = Struct.new(:min, :max)
map2 = Struct.new(:num, :range)
n = gets.to_i
a = gets.split.map(&:to_i)
b = Array.new(n).map{map2.new(0, map.new)}
c = Hash.new
d = Array.new
find = false
n.times do |i|
    if !c.has_key?(a[i])
        c[a[i]] = map.new(i, i)
    else
        c[a[i]].max = i
        find = true
    end
    d.push(a[i])
end
if !find
   puts a.join(" ")
   exit
end
d.uniq!.sort!{|a, b| b <=> a}
d.each do |x|
    r = c[x]
    t = map.new(r.min, r.max)
    i = r.min
    while i <= r.max do
        if b[i].num == 0
            b[i].num = x
            b[i].range = t
            i += 1
        else
            if b[i].range.min > r.min
                b[i].range.min = r.min
            end
            si = b[i].range.max + 1
            if b[i].range.max < r.max
                b[i].range.max = r.max
            end
            i = si
        end
    end
end
sp = false
b.each do |x|
    if sp
        print " "
    end
    print x.num
    sp = true
end
puts
0