vijos1055奶牛浴场

学一些东西,然后发现竟然敲过这道题目,不过一遍a掉还是很舒服的

#include<bits/stdc++.h>
using namespace std;
int x,y,ans=0,n,highest,lowest;
struct one{int x,y;};
one e[5010];
bool cmp(one aa,one bb){return aa.x<bb.x;}
bool dmp(one aa,one bb){return aa.y<bb.y;}
int main()
{
    scanf("%d%d",&x,&y);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d%d",&e[i].x,&e[i].y);
    sort(e+1,e+n+1,cmp);
    e[n+1].x=x;
    for(int i=1;i<=n;i++)
    {
        highest=y;lowest=0;
        for(int j=i+1;j<=n+1;j++)
        {
            if(e[j].x==e[i].x)continue;
            ans=max(ans,(e[j].x-e[i].x)*(highest-lowest));
            if(e[j].y>=e[i].y)highest=min(highest,e[j].y);
            if(e[j].y<=e[i].y)lowest=max(lowest,e[j].y);
        }
    }
    for(int i=n;i>=1;i--)
    {
        highest=y;lowest=0;
        for(int j=i-1;j>=0;j--)
        {
            if(e[j].x==e[i].x)continue;
            ans=max(ans,(e[i].x-e[j].x)*(highest-lowest));
            if(e[j].y>=e[i].y)highest=min(highest,e[j].y);
            if(e[j].y<=e[i].y)lowest=max(lowest,e[j].y);
        }
    }
    e[0].y=0;e[n+1].y=y;sort(e+1,e+n+1,dmp);
    for(int i=1;i<=n+1;i++)ans=max(x*(e[i].y-e[i-1].y),ans);
    printf("%d\n",ans);
    return 0;
}

 

posted @ 2020-08-29 10:08  mybing  阅读(103)  评论(0编辑  收藏  举报