Submission #51750693


Source Code Expand

N,K,*A = $<.read.split.map(&:to_i)

I = []
(N-1).times{|i|
	j = (i...N).min_by{|j| A[j] }
	(j-1).downto(i){|j|
		A[j+1],A[j] = A[j,2]
		A[j+1] += K
		I<<j+1
	}
}

warn A.each_cons(2).all?{_1<=_2}
puts I.size,I

Submission Info

Submission Time
Task I - Swap and Sort
User ds14050
Language Ruby (ruby 3.2.2)
Score 400
Code Size 224 Byte
Status AC
Exec Time 278 ms
Memory 21752 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 26
Set Name Test Cases
Sample example0.txt, example1.txt
All example0.txt, example1.txt, maximum0.txt, maximum1.txt, maximum2.txt, maximum3.txt, maximum4.txt, maximum5.txt, maximum6.txt, maximum7.txt, maximum8.txt, random0.txt, random1.txt, random10.txt, random11.txt, random12.txt, random13.txt, random14.txt, random2.txt, random3.txt, random4.txt, random5.txt, random6.txt, random7.txt, random8.txt, random9.txt
Case Name Status Exec Time Memory
example0.txt AC 124 ms 17164 KiB
example1.txt AC 44 ms 17272 KiB
maximum0.txt AC 56 ms 17584 KiB
maximum1.txt AC 57 ms 17396 KiB
maximum2.txt AC 199 ms 20312 KiB
maximum3.txt AC 276 ms 21716 KiB
maximum4.txt AC 278 ms 21648 KiB
maximum5.txt AC 276 ms 21752 KiB
maximum6.txt AC 273 ms 21432 KiB
maximum7.txt AC 276 ms 21656 KiB
maximum8.txt AC 276 ms 21676 KiB
random0.txt AC 71 ms 18180 KiB
random1.txt AC 44 ms 17244 KiB
random10.txt AC 61 ms 17780 KiB
random11.txt AC 45 ms 17444 KiB
random12.txt AC 85 ms 18420 KiB
random13.txt AC 98 ms 18544 KiB
random14.txt AC 109 ms 18952 KiB
random2.txt AC 127 ms 19044 KiB
random3.txt AC 91 ms 18516 KiB
random4.txt AC 44 ms 17424 KiB
random5.txt AC 45 ms 17360 KiB
random6.txt AC 149 ms 19440 KiB
random7.txt AC 211 ms 20544 KiB
random8.txt AC 135 ms 19296 KiB
random9.txt AC 101 ms 18696 KiB