Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
678 B
2
Indexable
Never
import java.util.*;

public class Main {

    public static void solve(int []arr, int n, int s){
        //Write your code here
		boolean flag = false;
		for(int i = 0; i<10; i++){
			int sum = 0;
			for(int j = i; j<10; j++){
				sum += arr[j];
				if(sum>s) break;
				if(j-i==n-1 && sum == s){
					flag = true;
					break;
				}
			}
		}
		if(flag) System.out.print("YES");
		else System.out.print("NO");
    }

    public static void main(String[] args) throws Throwable {
        Scanner sc = new Scanner(System.in);
        int []arr={1,2,3,4,5,6,7,8,9,10};
        int n;
        n=sc.nextInt();
        int s;
        s=sc.nextInt();
        solve(arr, n, s);
    }
}