题O:
Given a sequence with N integers A(1), A(2), …, A(N), your task is to find out a sequence B(1), B(2), …, B(N), such that V = (|A(1) – B(1)| + |A(2) – B(2)| + … + |A(N) – B(N)|) + (|B(1) – B(2)| + |B(2) – B(3)| + … +|B(N-1) – B(N)|)
is minimum. Input The first line in the input contains an integer N (1
关注
打赏