Submission #3229349


Source Code Expand

n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
placeOne = 0
for i in 0..(n-1) do
  if a[i] == 1
    placeOne = i
  end
end

count = placeOne / (k-1)
if placeOne % (k-1) != 0
  count += 1
  placeOne = count * (k-1)
end

rest = n - placeOne - 1
count += (rest / (k-1))
if rest % (k-1) != 0
  count += 1
end

p count

Submission Info

Submission Time
Task C - Minimization
User Kouch
Language Ruby (2.3.3)
Score 300
Code Size 366 Byte
Status AC
Exec Time 50 ms
Memory 8716 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 16
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt AC 24 ms 4476 KB
10.txt AC 40 ms 7180 KB
2.txt AC 50 ms 8716 KB
3.txt AC 33 ms 5644 KB
4.txt AC 49 ms 8460 KB
5.txt AC 49 ms 8716 KB
6.txt AC 50 ms 8716 KB
7.txt AC 10 ms 2172 KB
8.txt AC 44 ms 7820 KB
9.txt AC 7 ms 1788 KB
sample1.txt AC 7 ms 1788 KB
sample2.txt AC 7 ms 1788 KB
sample3.txt AC 7 ms 1788 KB