CF1548E.Gregor and the Two Painters
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Two painters, Amin and Benj, are repainting Gregor's living room ceiling! The ceiling can be modeled as an n×m grid.
For each i between 1 and n , inclusive, painter Amin applies ai layers of paint to the entire i -th row. For each j between 1 and m , inclusive, painter Benj applies bj layers of paint to the entire j -th column. Therefore, the cell (i,j) ends up with ai+bj layers of paint.
Gregor considers the cell (i,j) to be badly painted if ai+bj≤x . Define a badly painted region to be a maximal connected component of badly painted cells, i. e. a connected component of badly painted cells such that all adjacent to the component cells are not badly painted. Two cells are considered adjacent if they share a side.
Gregor is appalled by the state of the finished ceiling, and wants to know the number of badly painted regions.
输入格式
The first line contains three integers n , m and x ( 1≤n,m≤2⋅105 , 1≤x≤2⋅105 ) — the dimensions of Gregor's ceiling, and the maximum number of paint layers in a badly painted cell.
The second line contains n integers a1,a2,…,an ( 1≤ai≤2⋅105 ), the number of paint layers Amin applies to each row.
The third line contains m integers b1,b2,…,bm ( 1≤bj≤2⋅105 ), the number of paint layers Benj applies to each column.
输出格式
Print a single integer, the number of badly painted regions.
输入输出样例
输入#1
3 4 11 9 8 5 10 6 7 2
输出#1
2
输入#2
3 4 12 9 8 5 10 6 7 2
输出#2
1
输入#3
3 3 2 1 2 1 1 2 1
输出#3
4
输入#4
5 23 6 1 4 3 5 2 2 3 1 6 1 5 5 6 1 3 2 6 2 3 1 6 1 4 1 6 1 5 5
输出#4
6
说明/提示
The diagram below represents the first example. The numbers to the left of each row represent the list a , and the numbers above each column represent the list b . The numbers inside each cell represent the number of paint layers in that cell.
The colored cells correspond to badly painted cells. The red and blue cells respectively form 2 badly painted regions.