Two Seals codeforces 837c

Two Sealsios

 

一個矩形a*b,若干子矩形,子矩形中選2個,不重疊能覆蓋最大spa

 

思路:code

  枚舉;blog

 

代碼:get

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define maxn 105
int n,xi,yi,ai[maxn],bi[maxn],ans;
inline void in(int &now)
{
    char Cget=getchar();now=0;
    while(Cget>'9'||Cget<'0') Cget=getchar();
    while(Cget>='0'&&Cget<='9')
    {
        now=now*10+Cget-'0';
        Cget=getchar();
    }
}
int main()
{
    in(n),in(xi),in(yi);
    for(int i=1;i<=n;i++) in(ai[i]),in(bi[i]);
    for(int i=1;i<=n;i++)
    {
        int a=xi-ai[i],b=yi-bi[i];
        if(a>=0&&b>=0) for(int v=i+1;v<=n;v++)
        {
            if(ai[v]<=a&&bi[v]<=yi) ans=max(ai[i]*bi[i]+ai[v]*bi[v],ans);
            if(ai[v]<=b&&bi[v]<=xi) ans=max(ai[i]*bi[i]+ai[v]*bi[v],ans);
            if(bi[v]<=a&&ai[v]<=yi) ans=max(ai[i]*bi[i]+ai[v]*bi[v],ans);
            if(bi[v]<=b&&ai[v]<=xi) ans=max(ai[i]*bi[i]+ai[v]*bi[v],ans);
        }
        a=xi-bi[i],b=yi-ai[i];
        if(a>=0&&b>=0)for(int v=i+1;v<=n;v++)
        {
            if(ai[v]<=a&&bi[v]<=yi) ans=max(ai[i]*bi[i]+ai[v]*bi[v],ans);
            if(ai[v]<=b&&bi[v]<=xi) ans=max(ai[i]*bi[i]+ai[v]*bi[v],ans);
            if(bi[v]<=a&&ai[v]<=yi) ans=max(ai[i]*bi[i]+ai[v]*bi[v],ans);
            if(bi[v]<=b&&ai[v]<=xi) ans=max(ai[i]*bi[i]+ai[v]*bi[v],ans);
        }
    }
    cout<<ans;
    return 0;
}
相關文章
相關標籤/搜索