logo AlgoBeat OnlineJudge
登录 注册

#215413. [ICPC 2022 Tehran R] Ammunition Storage

内存限制:512 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

The Do-Barareh military area is like an grid, each cell of which has a specific height. The commander of this military area is looking for a rectangular sub-area of this area, with width and height least , whose its four corner cells are higher than the rest of its cells. He plans to install watchtowers in the corners of this sub-area to monitor the entire sub-area and use it for ammunition storage. Your job is to help the commander to find out how many valid sub-areas there are to choose as the ammunition storage. You can assume cell heights are distinct.

输入格式

The first line of input contains two space-separated integers and (). Each of the next lines contains space-separated integers showing the cell heights. It is guaranteed cell heights are distinct numbers between and (inclusive).

输出格式

Print the number of valid sub-areas to be used as an ammunition storage.

样例

样例输入 1

3 3
9 4 8
2 1 3
7 5 6

样例输出 1

7