划纸片 我只写出了第一行输入的这后不知道了

img

img


#include <iostream>
using namespace std;

int main()
{
    int n,m;//输入最大行列数
    int count_n,y;//输入每行划分次数和位置 
    int count_m,x;//输入每列划分次数和位置 

    int h_max = 0, w_max = 0;// 计算最大高度,最大宽度
    int last_y=1,last_x=1;   // 上次的位置,默认是1,因为起点就是1

    cin>>n>>m;// 输入最大行数,最大列数
    
    // 先处理行,相邻位置相减,得到高度
    // 找到最大高度
    cin>>count_n;
    for(int i=0;i<count_n;i++)
    {
        cin>>y;// 输入一个位置y
        int h = y-last_y;// 当前输入的位置y,与上一次的位置last减,得到高度
        if (h_max < h)// 如果已知的最大高度h_max 小于 这一次的高度h,则更新最大高度h_max
        {
            h_max = h;
        }
        last_y = y;//将当前位置y赋值给last,即记住新的"上一次位置"
    }
    // 最后一个位置处理完毕后,计算一下与最右边边境的距离
    if (n-last_y > h_max)
    {
        h_max = n-last_y;
    }

    // 再处理列,相邻位置相减,得到宽度
    // 找到最大宽度
    cin>>count_m;
    for(int i=0;i<count_m;i++)
    {
        cin>>x;
        int w = x-last_x;
        if (w_max < w)
        {
            w_max = w;
        }
        last_x = x;
    }
    if (m-last_x > w_max)
    {
        w_max = m-last_x;
    }
    
    // 最大高度 * 最大宽度即最大面积
    cout<<h_max * w_max;
   
    return 0;
}