from collections import defaultdict as dd
from collections import deque
import bisect
import heapq
def ri():
return int(input())
def rl():
return list(map(int, input().split()))
def solve():
n, x = rl()
A = rl()
copies = dd(int)
for a in A:
if a >= x: continue
copies[a] += 1
curr = x - 1
need = 0
factor = x
while curr >= 1:
if need == 0 and copies[curr] != 0:
need = factor
if need > n:
print ("No")
return
if need != 0:
if need >= copies[curr]:
need -= copies[curr]
else:
need = (need-copies[curr]) % factor
need *= curr
if factor <= n * 1000000:
factor *= curr
curr -= 1
if need == 0:
print ("Yes")
else:
print ("No")
mode = 's'
if mode == 'T':
t = ri()
for i in range(t):
solve()
else:
solve()
#include<bits/stdc++.h>
using namespace std;
int a[1000009];
int main () {
int n, m, ans = 1;
cin >> n >> m;
int b[n];
for (int i = 0; i < n; i++) {
cin >> b[i];
a[b[i]]++;
if (b[i] < m) ans = 0;
}
if (ans) cout << "Yes";
else {
ans = 1;
for (int i = 1; i < m; i++) {
if ((a[i]%(i+1)) == 0) {
a[i+1] += (a[i]/(i+1));
continue;
}
else {
ans = 0;
break;
}
}
if (ans) cout << "Yes";
else cout << "No";
}
}
1627B - Not Sitting | 1663C - Pōja Verdon |
1497A - Meximization | 1633B - Minority |
688B - Lovely Palindromes | 66B - Petya and Countryside |
1557B - Moamen and k-subarrays | 540A - Combination Lock |
1553C - Penalty | 1474E - What Is It |
1335B - Construct the String | 1004B - Sonya and Exhibition |
1397A - Juggling Letters | 985C - Liebig's Barrels |
115A - Party | 746B - Decoding |
1424G - Years | 1663A - Who Tested |
1073B - Vasya and Books | 195B - After Training |
455A - Boredom | 1099A - Snowball |
1651D - Nearest Excluded Points | 599A - Patrick and Shopping |
237A - Free Cash | 1615B - And It's Non-Zero |
1619E - MEX and Increments | 34B - Sale |
1436A - Reorder | 1363C - Game On Leaves |