PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000125. Tổng giá các phần ăn (Set Menu)
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 giá các phần ăn (Set Menu)
Set Menu
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A cafeteria offers types of main dishes at prices and types of side dishes at prices . A set meal consists of one main and one side. Its price is , capped at . There are exactly distinct main-side choices, even when prices match. Compute the sum of prices of all possible set meals.
Input
The first line contains . The second contains main-dish prices . The third contains side-dish prices .
Output
Print one integer: the total price of all set meals (fits signed 64-bit).
Subtasks
- Subtask 1 (20 points): ; for , .
- Subtask 2 (30 points): ; for , .
- Subtask 3 (50 points): ; for , .
Examples
Input
2 2 7
3 5
6 1
Output
24
Explanation
There are four meals: costs , costs , costs , and costs . Their total is , so print 24.