提出 #43950581


ソースコード 拡げる

(N,),A,B = $<.map{|ln| ln.split.map{_1.to_i} }
B<<0

sum = 0
cs = []
k01 = 1<<28
k10 = 2<<28
k11 = 3<<28
m = (1<<29)-1
28.times{
	k01>>=1
	k10>>=1
	k11>>=1
	m>>=1
	A.map!{ _1&m }.sort!
	B.pop
	B.map!{ _1&m }.sort!<<k11
	one = carry = N&1
	ia = i01 = i10 = i11 = 0
	while a = A[ia-=1]
		i01 += 1 while a+B[i01]<k01
		i10 += 1 while a+B[i10]<k10
		i11 += 1 while a+B[i11]<k11
		one += i11+i10+i01
		carry += i10
	end
	cs<<carry
	sum += k01 if 0<one&1
}
sum += 1<<28 if 0<cs[0]&1

p sum

提出情報

提出日時
問題 D - Two Sequences
ユーザ ds14050
言語 Ruby (2.7.1)
得点 500
コード長 516 Byte
結果 AC
実行時間 2106 ms
メモリ 43552 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 4
AC × 16
セット名 テストケース
Sample example_0, example_1, example_2, example_3
All N100000_0, N100000_1, N150000_0, N150000_1, N200000_0, N200000_1, N200000_ex_0, N200000_ex_1, example_0, example_1, example_2, example_3, rand_0, rand_1, smallrand_0, smallrand_1
ケース名 結果 実行時間 メモリ
N100000_0 AC 1068 ms 27940 KiB
N100000_1 AC 1066 ms 27748 KiB
N150000_0 AC 1588 ms 36032 KiB
N150000_1 AC 1583 ms 36028 KiB
N200000_0 AC 2106 ms 43520 KiB
N200000_1 AC 2099 ms 43476 KiB
N200000_ex_0 AC 2081 ms 43476 KiB
N200000_ex_1 AC 2084 ms 43552 KiB
example_0 AC 55 ms 14064 KiB
example_1 AC 55 ms 14192 KiB
example_2 AC 58 ms 14100 KiB
example_3 AC 54 ms 14196 KiB
rand_0 AC 118 ms 15012 KiB
rand_1 AC 189 ms 15796 KiB
smallrand_0 AC 56 ms 14060 KiB
smallrand_1 AC 55 ms 14040 KiB