PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000100. Doanh thu sân bay (Airport)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Doanh thu sân bay (Airport)
Airport
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are aircraft with empty seats and passengers purchasing tickets one after another. A ticket on a plane with currently empty seats costs exactly units, and then the seat count decreases. Each passenger may choose any plane with an empty seat. Find maximum and minimum total revenue.
Input
Line 1 contains . Line 2 contains integers .
Output
Print two integers on one line: maximum revenue and then minimum revenue.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
4 3
2 2 2
Output
7 6
Explanation
Maximum revenue is by selling first seats on three planes. Minimum is by exhausting one plane before moving to another.