PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000058. Hai người bạn hay ghen (Jealous Two)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Hai người bạn hay ghen (Jealous Two)
Jealous Two
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are candidate gifts. Person one values gift at , and person two values it at . Assign one gift to each person (the same gift may be chosen twice). Count ordered assignments in which each person values their own gift at least as highly as the other person's gift.
Input
The first line contains , followed by the array and then the array .
Output
Print the number of valid ordered assignments.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
3
50 100 150
1 3 2
Output
4
Explanation
The three choices giving both people the same gift and the ordered choice (gift 3 for person one, gift 2 for person two) make four assignments.