You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <bits/stdc++.h>
using namespace std ;
typedef pair < int , int > PII ;
# define x first
# define y second
PII a [ 110 ] ;
int n , L ;
vector < int > X , Y ;
int ans ;
int main ( ) {
cin > > n > > L ;
for ( int i = 1 ; i < = n ; + + i ) {
cin > > a [ i ] . x > > a [ i ] . y ;
/*
( 1) 按照输入的坐标先把所有可能的最终边长为L的正方形左上角坐标保存起来
( 2) 枚举正方形的左上角, 再去统计一下有多少点在这个正方形中。取最大值。
*/
X . push_back ( a [ i ] . x ) ;
X . push_back ( a [ i ] . x - L ) ; // 边长固定是L
Y . push_back ( a [ i ] . y ) ;
Y . push_back ( a [ i ] . y - L ) ;
}
for ( int i = 0 ; i < X . size ( ) ; i + + )
for ( int j = 0 ; j < Y . size ( ) ; j + + ) { // 枚举所有可能的左上角坐标
int cnt = 0 ;
int x = X [ i ] , y = Y [ j ] ;
for ( int k = 1 ; k < = n ; k + + ) // 枚举每个金矿
if ( a [ k ] . x > = x & & a [ k ] . x < = x + L & & a [ k ] . y > = y & & a [ k ] . y < = y + L )
cnt + + ;
ans = max ( ans , cnt ) ;
}
cout < < ans < < endl ;
return 0 ;
}