728x90
grid(w,h)와 보물개수, 사각형
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
int main()
{
int w,h,t,s;
std::cin>>w;
std::cin>>h;
std::cin>>t;
std::cin>>s;
std::vector<std::pair<int,int>> pos;
for(int i=0;i<t;i++){
int x,y;
std::cin>>x;
std::cin>>y;
pos.push_back(make_pair(x,y));
}
int max_num=0;
for(int x=0;x<=w-s;x++){
for(int y=0;y<=h-s;y++){
int cnt=0;
for(auto &p:pos){
// p.first
// p.second
if(x<=p.first && x+s>=p.first && y<=p.second && y+s>=p.second){
cnt++;
}
}
if (cnt>max_num){
max_num=cnt;
}
}
}
std::cout<<max_num;
return 0;
}
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <cstdio>
int main()
{
int w,h,t,s;
std::cin >> w>>h>>t>>s;
std::vector<std::pair<int,int>> pos;
for(int i=0;i<t;i++){
int x,y;
std::cin >> x>>y;
pos.push_back(std::make_pair(x,y));
}
int max_count = INT_MIN;
for(auto &x:pos){
for(auto &y:pos){
int count = 0;
for(auto &p:pos){
if(p.first>=x.first && p.first<=x.first+s && p.second <= y.second+s && p.second >=y.second){
count ++;
}
}
max_count=std::max(count,max_count);
}
}
std::cout<<max_count;
return 0;
}