HÀNG CÂY

Nộp bài
Time limit: 1.0 / Memory limit: 256M

Point: 10

Đề bài

Ví dụ:

Input
5 5
3 1 5 2 4
2 5
1 4
1 3
3 5
4 5
Output
7
5
3
3
1

Mirror

Nguồn


BỘ BA

Nộp bài
Time limit: 1.0 / Memory limit: 256M

Point: 10

Đề bài

Ví dụ:

Input
7
5 9 10 7 1 4 8
Output
25

Nguồn