👨🏫 乘飞机
🐷 抽屉原理
import java.util.Scanner;
public class Main
{
static int N = 100010;
static int[] a = new int[N];
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
for (int i = 1; i <= n; i++)
a[i] = sc.nextInt();
while (q-- > 0)
{
int l = sc.nextInt();
int r = sc.nextInt();
if (r - l >= 100)
System.out.println("YES");
else
cal(l, r);
}
}
private static void cal(int l, int r)
{
boolean res = false;
for (int i = l; i <= r; i++)
for (int j = i + 1; j <= r; j++)
if (Math.abs(a[i] - a[j]) <= 365)
{
System.out.println("YES");
return;
}
System.out.println("NO");
}
}