川のブログ

川の適当気ままなブログです。 

AOJ 1125 Get Many Persimmon Trees

こんにちは川です。

今回は、間に合いそうだったので、貪欲に確かめていっています。

 

ソースコード

 

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    while(cin>>n,n){
        int wh,hi;
        cin>>wh>>hi;
        bool place[100][100]={};
        for(int i=0,x,y;i<n;i++){
            cin>>x>>y;
            place[y][x]=1;
        }
        int w,h,ans=0;
        cin>>w>>h;
        for(int i=1;i<=hi-h+1;i++){
            for(int j=1;j<=wh-w+1;j++){
                int co=0;
                for(int k=i;k<i+h;k++)
for(int l=j;l<j+w;l++)
if(place[k][l]==1)co++;
                ans=max(co,ans);
            }
        }
        cout<<ans<<endl;
    }
}