PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000159. Tăng phần tử để đạt tần suất lớn nhất (To Add or Not to Add)
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 phần tử để đạt tần suất lớn nhất (To Add or Not to Add)
To Add or Not to Add
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given integers and may perform at most operations. Each operation increments one chosen element by exactly ; the same element may be chosen repeatedly. Maximize the frequency of any value after the operations. If several values achieve the maximum frequency, output the smallest such value.
Input
- The first line contains .
- The second line contains integers .
Output
Print the maximum achievable frequency followed by the smallest value that achieves it.
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every .
- Subtask 3 (50 points): ; ; for every .
Examples
Input
5 3
6 3 4 0 2
Output
3 4
Explanation
Starting from with , increment once and twice to obtain . Thus occurs three times. Four equal values cannot be obtained within three operations, so print 3 4.