NIZOVI | 프로그래밍의 벗 PivotOJ
PivotOJ

NIZOVI

시간 제한: 1000ms메모리 제한: 128MB출처: CHC 2009 Regional Competition - SeniorsBOJ 8973

문제

Marko's math notebook has two sequences of integers written in it, both of length N. The fuzziness of these sequences is calculated by first reversing the order of the elements in the second sequence and then adding the products of elements in the same positions of the two sequences. 

3 -4 -3 -2 2 0
-3 0 5 -1 3 2

For example, the fuzziness of the above two sequence of length 6 is 3·2 + (−4)·3 + (−3)·(−1) + (−2)·5 + 2·0 + 0·(−3) = −13. 

Mirko likes his pairs of sequences to be as fuzzy as possible. He decided to remove B numbers (possibly zero) from the beginning of both sequences and also E numbers (possibly zero) from the end of both sequences, so that the fuzziness is as large as possible. 

Write a program that finds the values of B and E for which the fuzziness is largest. 

입력

The first line of input contains the integer N (1 ≤ N ≤ 2000), the length of Marko's sequences. 

The following two lines contain N integers each, the two sequences. All numbers in the two sequences will be between −1000 and 1000. 

출력

Output two integers B and E on the first line, such that 0 ≤ P, K < N and P+K < N. 

Output the resulting fuzziness on the second line. 

If multiple choices of B and E achieve the largest fuzziness, output any of them. 

예제

예제 1

입력
6
3 -4 -3 -2 2 0
-3 0 5 -1 3 2
출력
0 3
24

예제 2

입력
5
1 1 1 1 1
2 2 2 2 2
출력
0 0
10

예제 3

입력
5
5 -5 -5 -5 5
-5 -5 5 -5 -5
출력
2 0
75
코드를 제출하려면 로그인하세요.