PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000155. Đoạn ngày làm việc hiệu quả dài nhất (Longest Well-Performing Interval)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đoạn ngày làm việc hiệu quả dài nhất (Longest Well-Performing Interval)
Longest Well-Performing Interval
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given daily working hours , a day is tiring when its hours are strictly greater than 8. All other days, including exactly 8 hours, are non-tiring. Find the longest contiguous interval containing strictly more tiring days than non-tiring days. Print 0 if no such interval exists.
Input
- Line 1: integer , the number of days.
- Line 2: integers in order.
Output
Print one integer: the maximum qualifying interval length.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Example 1
Input
7
9 9 6 0 6 6 9
Output
3
Explanation
Interval [1,3] has two tiring days and one other day. For lengths 4, 5, 6, 7, the maximum tiring-day counts are 2, 2, 2, 3 respectively, never more than half.
Example 2
Input
3
6 6 6
Output
0
Explanation
There are no tiring days, so no nonempty interval qualifies.