跳到正文

个人记录

dfsg

Zhouyanbo约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年9月9日
收录
2026年9月9日
更新
2026年9月9日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include <bits/stdc++.h>
using namespace std;
int n, x, a[500005];
int main(){
    cin >> n >> x;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= x - 1; i++) if (a[i] / (i + 1)) a[i + 1] += a[i] / (i + 1), a[i] = a[i] % (i + 1);
    for (int i = 1; i <= x - 1; i++) if (a[i]) {cout << "No"; return 0;}
    for (int i = x; i <= 500000; i++) if (a[i]){ cout << "Yes"; return 0;}
    cout << "No";
    return 0;
}
原文