시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 29 9 8 53.333%

문제

창영이의 수학 공책에는 길이가 N이고 정수로 이루어진 수열 두 개가 적혀져 있다. 두 수열의 흐릿함을 계산하려면, 두 번째 수열을 뒤집은 다음, 같은 위치에 있는 두 수의 곱을 더해야 한다.

예를 들어, 위의 두 수열의 흐릿함은 3×2 + (-4)×3 + (-3)×(-1) + (-2)×5 + 2×0 + 0×(-3) = -13 이다.

창영이는 앞에서부터 B개, 뒤에서부터 E개를 지워서 두 수열의 흐릿함을 되도록 크게 만드려고 한다. B와 E는 0일 수도 있으며, 수를 지울 때는 두 수열에서 동시에 지워야 한다.

흐릿함을 가장 크게 만드려면, B와 E가 몇이 되어야 하는지 구하는 프로그램을 작성하시오.

입력

첫째 줄에 수열의 길이 N (1 ≤ N ≤ 2000)이 주어진다.

다음 두 줄에 걸쳐서 두 수열이 주어진다. 모든 숫자는 -1000보다 크거나 같고, 1000보다 작거나 같다.

출력

첫째 줄에 B와 E를 출력한다. (0 ≤ B, E < N, B+E < N)

둘째 줄에는 흐릿함의 최댓값을 출력한다.

흐릿함을 최대로 만드는 B와 E가 여러 가지인 경우에는 아무거나 출력한다.

예제 입력 1

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

예제 출력 1

0 3
24
W3sicHJvYmxlbV9pZCI6Ijg5NzMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMyMThcdWQ1NTkgXHVhY2Y1XHVjYzQ1IiwiZGVzY3JpcHRpb24iOiI8cD5cdWNjM2RcdWM2MDFcdWM3NzRcdWM3NTggXHVjMjE4XHVkNTU5IFx1YWNmNVx1Y2M0NVx1YzVkMFx1YjI5NCBcdWFlMzhcdWM3NzRcdWFjMDAgTlx1Yzc3NFx1YWNlMCBcdWM4MTVcdWMyMThcdWI4NWMgXHVjNzc0XHViOGU4XHVjNWI0XHVjOWM0IFx1YzIxOFx1YzVmNCBcdWI0NTAgXHVhYzFjXHVh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