提出 #28467644
ソースコード 拡げる
class BIT
def initialize n
@z = n+1
@a = Hash.new 0
end
def [] i
i += 1
s = 0
while 0<i
s += @a[i]
i &= i-1
end
return s
end
def index s
i,t,b = 0,0,1<<(@z-1).bit_length
t += @a[i|=b] if i|b<@z && t+@a[i|b]<s while 0 < b>>=1
return i if s<=self[i]
end
def add i,d
i += 1
while i<@z
@a[i] += d
i += i&-i
end
end
end
N,Q = gets.split.map(&:to_i)
S = gets.split
Qry = $<.map(&:split)
T = (S|Qry.map{_2}).sort
J = T.each_with_index.to_h
X = BIT.new J.size-1<<17|N
S.each_with_index{|s,i|
X.add J[s]<<17|i,1
}
Qry.each{|x,t|
k = X.index x.to_i
X.add k,-1
X.add J[t]<<17|k&131071,1
}
A = [nil]*N
1.upto(N){|x|
k = X.index x
A[k&131071] = T[k>>17]
}
puts A
提出情報
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 6 / 6 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example0.txt, example1.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, example0.txt, example1.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 2531 ms | 128140 KiB |
| 001.txt | AC | 1218 ms | 74912 KiB |
| 002.txt | AC | 999 ms | 66388 KiB |
| 003.txt | AC | 58 ms | 14260 KiB |
| 004.txt | AC | 2528 ms | 128388 KiB |
| 005.txt | AC | 2484 ms | 128184 KiB |
| 006.txt | AC | 2576 ms | 128332 KiB |
| 007.txt | AC | 2582 ms | 128548 KiB |
| 008.txt | AC | 863 ms | 69728 KiB |
| 009.txt | AC | 880 ms | 62884 KiB |
| 010.txt | AC | 2894 ms | 149088 KiB |
| 011.txt | AC | 1518 ms | 115592 KiB |
| 012.txt | AC | 2064 ms | 86312 KiB |
| 013.txt | AC | 2290 ms | 125692 KiB |
| 014.txt | AC | 2032 ms | 84032 KiB |
| 015.txt | AC | 2294 ms | 125072 KiB |
| 016.txt | AC | 2259 ms | 127504 KiB |
| 017.txt | AC | 2379 ms | 127596 KiB |
| 018.txt | AC | 2244 ms | 124976 KiB |
| 019.txt | AC | 2260 ms | 125032 KiB |
| 020.txt | AC | 1698 ms | 74424 KiB |
| 021.txt | AC | 1653 ms | 71496 KiB |
| 022.txt | AC | 1722 ms | 71324 KiB |
| 023.txt | AC | 1786 ms | 71512 KiB |
| 024.txt | AC | 1786 ms | 71484 KiB |
| 025.txt | AC | 947 ms | 45908 KiB |
| 026.txt | AC | 938 ms | 46412 KiB |
| 027.txt | AC | 948 ms | 46496 KiB |
| 028.txt | AC | 934 ms | 46420 KiB |
| 029.txt | AC | 932 ms | 45976 KiB |
| 030.txt | AC | 974 ms | 46292 KiB |
| 031.txt | AC | 954 ms | 46188 KiB |
| 032.txt | AC | 964 ms | 46480 KiB |
| example0.txt | AC | 57 ms | 14140 KiB |
| example1.txt | AC | 55 ms | 13992 KiB |