cf/mirror

Turtle and Three Sequences

CF
2003F2800· international gm3s256 MB⌨ stdin/stdout

Examples

Sample 1of 3
Input
4 2
2 3 4 2
1 3 3 2
1 4 2 3
Output
5
Sample 2of 3
Input
7 3
1 4 5 2 3 6 7
1 2 2 1 1 3 2
1 5 6 7 3 2 4
Output
13
Sample 3of 3
Input
5 3
1 2 3 4 5
1 1 2 1 2
5 4 3 2 1
Output
-1
2003F.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)