PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000241. Tổng các phần tử nhỏ nhất (Least Elements)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng các phần tử nhỏ nhất (Least Elements)
Least Elements
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given integers , consider every contiguous window of exactly elements in left-to-right order. For each window, compute the sum of its smallest entries, counting repeated values with their multiplicity. Treat windows independently.
Input
The first line contains integers . The second contains integers .
Output
Print space-separated integers in window order.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; ; ; the bound on applies for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
5 3 2
7 2 2 9 1
Output
4 4 3
Explanation
The windows are , , and . Their two smallest entries are , , and , giving 4,4,3.