Submission #2540642


Source Code Expand

n = gets.to_i
p = []
pos = []
n.times do |i|
  p[i] = gets.to_i-1
  pos[p[i]] = i
end
max = 1
con = 1
for i in 1...n do
  if pos[i-1] < pos[i]
    con += 1
  else
    max = [max, con].max
    con = 1
  end
end
max = [max, con].max

puts n - max

Submission Info

Submission Time
Task B - Backfront
User rankey55
Language Ruby (2.3.3)
Score 500
Code Size 263 Byte
Status AC
Exec Time 186 ms
Memory 7112 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 28
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 164 ms 5064 KiB
02.txt AC 161 ms 5372 KiB
03.txt AC 161 ms 5448 KiB
04.txt AC 163 ms 5448 KiB
05.txt AC 165 ms 7112 KiB
06.txt AC 163 ms 5064 KiB
07.txt AC 133 ms 4976 KiB
08.txt AC 136 ms 5360 KiB
09.txt AC 186 ms 5372 KiB
10.txt AC 186 ms 5372 KiB
11.txt AC 132 ms 5448 KiB
12.txt AC 134 ms 5064 KiB
13.txt AC 133 ms 5372 KiB
14.txt AC 132 ms 5372 KiB
15.txt AC 132 ms 5448 KiB
16.txt AC 135 ms 5064 KiB
17.txt AC 154 ms 5064 KiB
18.txt AC 154 ms 5064 KiB
19.txt AC 131 ms 5032 KiB
20.txt AC 131 ms 4964 KiB
21.txt AC 159 ms 5064 KiB
22.txt AC 161 ms 5064 KiB
23.txt AC 7 ms 1788 KiB
24.txt AC 7 ms 1788 KiB
25.txt AC 7 ms 1788 KiB
s1.txt AC 7 ms 1788 KiB
s2.txt AC 7 ms 1788 KiB
s3.txt AC 7 ms 1788 KiB