結果

問題 No.1705 Mode of long array
ユーザー 小野寺健小野寺健
提出日時 2021-11-30 10:15:29
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 841 bytes
コンパイル時間 618 ms
コンパイル使用メモリ 11,212 KB
実行使用メモリ 155,680 KB
最終ジャッジ日時 2023-09-16 01:58:16
合計ジャッジ時間 10,897 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
19,604 KB
testcase_01 AC 78 ms
15,312 KB
testcase_02 AC 79 ms
15,116 KB
testcase_03 AC 100 ms
18,516 KB
testcase_04 AC 98 ms
20,044 KB
testcase_05 AC 103 ms
19,060 KB
testcase_06 AC 173 ms
22,180 KB
testcase_07 AC 178 ms
19,940 KB
testcase_08 AC 170 ms
18,988 KB
testcase_09 AC 157 ms
17,732 KB
testcase_10 AC 156 ms
18,168 KB
testcase_11 AC 177 ms
21,684 KB
testcase_12 AC 169 ms
20,140 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split(" ").map{|s| s.to_i}
a = gets.split(" ").map{|s| s.to_i}
ary = []
hash = {}
a.each_with_index {|x, i|
	hash[i+1] = x
	ary << [x, i+1]
}

ary.sort!

Q = gets.to_i
q = []
Q.times {
	q << gets.split(" ").map{|s| s.to_i}
}

q.each {|t, x, y|
	if t == 1 then
		v = hash[x]
		hash[x] = v + y
		i = ary.bsearch_index{|z| (z <=> [v, x]) >= 0}
		ary = ary[0, i] + ary[i+1..-1]
		i = ary.bsearch_index{|z| (z <=> [v + y, x]) >= 0}
		if i then
			ary = ary[0, i] + [[v + y, x]] + ary[i..-1]
		else
			ary << [v + y, x]
		end
	elsif t == 2 then
		v = hash[x]
		hash[x] = v - y
		i = ary.bsearch_index{|z| (z <=> [v, x]) >= 0}
		ary = ary[0, i] + ary[i+1..-1]
		i = ary.bsearch_index{|z| (z <=> [v - y, x]) >= 0}
		if i then
			ary = ary[0, i] + [[v - y, x]] + ary[i..-1]
		else
			ary << [v - y, x]
		end
	else
		puts ary[-1][1]
	end
}
0