PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000024. Tích vô hướng nhỏ nhất (Minimum Scalar Product)
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ích vô hướng nhỏ nhất (Minimum Scalar Product)
Minimum Scalar Product
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
Given two integer vectors of length , you may independently permute their elements. Find the minimum possible scalar product.
Input
The first line contains . The second and third lines contain vectors and .
Output
Print the minimum scalar product.
Constraints
- .
- for .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): Full constraints.
Examples
Input
3
1 3 -5
-2 4 1
Output
-25
Explanation
The sample follows the ordering rule described in the Vietnamese explanation and produces the shown optimum.