Submit solution
Points:
10
Time limit:
1.0s
Memory limit:
16M
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
Consider two descending sequences of integers and with and and for all , . The distance between two elements and is given by
if and , or otherwise
The distance between sequence and sequence is defined by
You may assume .
For example, for the sequences and below, their maximum distance is reached for and , so .
i=2

v
X 8 8 4 4 4 3 3 3 1
Y 9 9 8 8 6 5 5 4 3
^

j=7
Sample Input
2
9
8 8 4 4 4 3 3 3 1
9 9 8 8 6 5 5 4 3
7
6 5 4 4 4 4 4
3 3 3 3 3 3 3
Sample Output
The maximum distance is 5
The maximum distance is 0
Comments
For anyone who doesn't understand this problem, you have to basically find the maximum distance between two values in the arrays given
n
times.On line 1, there is a single integer
n
.l
.l
integers.Repeat steps 1 & 2
n
times.Hope this helps you understand the problem a bit better.
Can someone help me understand this a bit better?
why is this brute force question worthing 10 points?
I think it was that teachers actually marked the CCC before, so they had to manually input everything instead of having generated test cases. RIP teachers. They probably wanted to make it look scary.
I binary searched by successive submissions and it seems like
[Computers were probably too slow in 1996 but...]
Yeah... the test cases seem a bit weak. The same problem on PEG has but I don't think a brute force approach passes due to the addition of more cases.