영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
시간 제한 1초 · 메모리 제한 512 MB
Problem
You are given two arrays of n integers.
Your task is to select a nonempty prefix from both arrays such that the average of all selected numbers is as large as possible.
Input
The first line has an integer n.
The second line has n integers a_1,a_2,…,a_n: the numbers in the first array.
The third line has n integers b_1,b_2,…,b_n: the numbers in the second array.
Output
Print two numbers: the prefix sizes.
Your answer is considered correct if the absolute or relative difference to the maximum average is at most 10^-6.
Constraints
- 1 ≤ n ≤ 10^5
- 1 ≤ a_i, b_i ≤ 10^9
Example
Explanation: if you choose the prefixes [1,5,5] and [3], the average is (1+5+5+3)/4=3.5 which is the maximum possible average.
예제
예제 1
4 1 5 5 2 3 1 3 1
3 1