PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000400. Đoạn con có trung bình lớn nhất (Maximum Average Segment)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đoạn con có trung bình lớn nhất (Maximum Average Segment)

Maximum Average Segment

Version: Phuoc Hung OJ Extended

PHOJ practice edition. Its constraints, input/output format, examples and judging rules are specified below.

Problem Statement

Given an integer array of length nn and an integer kk, select a contiguous segment from index ll to rr of length at least kk with maximum arithmetic mean. Any optimal segment is accepted.

Input

The first line contains n,kn,k. The second line contains nn integers aia_i.

Output

Print two integers l,rl,r (1-based) specifying an optimal segment. Its mean must be exactly optimal; no floating-point tolerance is used.

Subtasks

  • Subtask 1 (20 points): 1≤k≤n≤301\le k\le n\le 30; 0≤ai≤1000\le a_i\le100.
  • Subtask 2 (30 points): 1≤k≤n≤10001\le k\le n\le 1000; 0≤ai≤1000\le a_i\le100.
  • Subtask 3 (50 points): 1≤k≤n≤1000001\le k\le n\le 100000; 0≤ai≤1000\le a_i\le100.

Created examples

Input

6 4
1 12 0 0 50 3

Output

2 5

Explanation

With n=6,k=4n=6,k=4, the length-4 segments have sums 13, 62 and 53; the largest mean in that group is 62/4=15.562/4=15.5. The length-5 means are 63/5=12.663/5=12.6 and 65/5=1365/5=13. The length-6 mean is 66/6=1166/6=11. Hence indices 2 through 5 are optimal.

Input

4 2
0 0 0 0

Output

1 2

Explanation

All four elements are zero. Every segment of length at least 2 has sum and mean zero. Indices 1 through 2 describe one valid optimal segment.

Input

3 3
100 0 5

Output

1 3

Explanation

Since n=k=3n=k=3, only the segment from 1 through 3 is long enough. Its sum is 100+0+5=105100+0+5=105 and its mean is 105/3=35105/3=35. Output indices 1 and 3.