PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CT0000059. Trung bình đoạn (Segment Average)
Bài tập này chưa được xếp vào lộ trình.
Mục lục đề ⌄
Đang đọc
Trung bình đoạn (Segment Average)
Segment Average
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer sequence and a positive integer . For every contiguous segment of length at least , define
Find the largest integer for which there exists at least one segment with and .
Input
The first line contains .
The second line contains .
Output
Print the largest valid integer .
Subtasks
- Subtask 1 (20%): .
- Subtask 2 (20%): .
- Subtask 3 (30%): .
- Subtask 4 (30%): , .
Examples
Example 1
Input
5 2
1 12 -5 -6 50
Output
22
Explanation
Segment has average , and no valid segment has a larger average.
Example 2
Input
4 3
-5 -2 -3 -4
Output
-3
Explanation
Segment has average , hence .
Example 3
Input
5 3
10 1 1 1 10
Output
4
Explanation
The whole array has average . Since must be an integer, the largest possible value is .
Liên quan
Trong các cuộc thi sau: