import sys, array, bisect, collections, heapq, itertools, math
sys.setrecursionlimit(100000)
def _r(): return sys.stdin.buffer.readline()
def rs(): return _r().decode('ascii').strip()
def rn(): return int(_r())
def rnt(): return tuple(map(int, _r().split()))
def rnl(): return list(rnt())
def rna(): return array.array('q', rnt())
def pnl(l): print(' '.join(map(str, l)))
def solve(n, x, a):
cnts = [0]*x
for num in a:
cnts[num-1] += 1
for i in range(x-1):
while cnts[i] >= i+2:
cnts[i] -= i+2
cnts[i+1] += 1
return sum(cnts[i] for i in range(x-1)) == 0
n, x = rnt()
a = rnl()
print('YES' if solve(n, x, a) else 'NO')
// - kylezft -
#include <bits/stdc++.h>
using namespace std;
#define task_ "task"
#define fst() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fin() freopen(task_".inp", "r", stdin)
#define fout() freopen(task_".out", "w", stdout)
#define ll long long
#define inf 2e9
#define oo 2e18
#define sz(s) int(s.size())
#define fi first
#define se second
#define bit(k, n) ((n >> k) & 1)
#define cntbit(n) __builtin_popcount(n)
mt19937 rd(chrono::high_resolution_clock::now().time_since_epoch().count());
// - <\> -
const int N = 5e5 + 2;
int n, a[N], x, cnt[N];
int main() {
fst();
cin >> n >> x;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
++cnt[a[i]];
}
bool ok = true;
for (int i = 1; i < x; ++i) {
if (cnt[i] >= i + 1) {
cnt[i + 1] += cnt[i] / (i + 1);
cnt[i] %= i + 1;
}
if (cnt[i] != 0) ok = false;
}
cout << (ok ? "Yes" : "No");
}
1088B - Ehab and subtraction | 1270B - Interesting Subarray |
478C - Table Decorations | 1304C - Air Conditioner |
1311C - Perform the Combo | 1519C - Berland Regional |
361A - Levko and Table | 5E - Bindian Signalizing |
687A - NP-Hard Problem | 1542C - Strange Function |
961E - Tufurama | 129D - String |
888A - Local Extrema | 722B - Verse Pattern |
278A - Circle Line | 940A - Points on the line |
1742C - Stripes | 1742F - Smaller |
1742B - Increasing | 1742A - Sum |
1742D - Coprime | 390A - Inna and Alarm Clock |
1398B - Substring Removal Game | 1742G - Orray |
416B - Art Union | 962A - Equator |
803B - Distances to Zero | 291A - Spyke Talks |
1742E - Scuza | 1506D - Epic Transformation |