1 solutions

  • 0
    @ 2022-10-24 22:26:54
    #include<bits/stdc++.h>
    using namespace std;
    #define ioio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define endl "\n"
    #define debug(x) cout<<#x<<":"<<x<<endl;
    #define P pair
    #define P1 first
    #define P2 second
    #define u_map unordered_map
    #define p_queue priority_queue
    typedef long long ll;
    const double eps = 1e-6;
    const int mod = 1e9 + 7;
    const int INF = 0x3f3f3f3f;
    const int N = 5e5 + 7;
    int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
    /*-------------------------------------------------*/
    
    ll n,x;
    int cnt[N];
    
    void slove() {
    	cin>>n>>x;
    	for(int i=1;i<=n;i++){
    		cin>>a[i];
    		if(a[i]<x)cnt[a[i]]++;
    	}
    	while(n--){
    		int num;
    		cin>>num;
    		if(num<x)continue;
    		cnt[num]++;
    	}
    	for(int i=1;i<x;i++){
    		if(cnt[i]==0)continue;
    		if(cnt[i]%(i+1)!=0){
    			cout<<"No"<<endl;
    			return ;
    		}else{
    			cnt[i+1]+=cnt[i]/(i+1);
    		}
    	}
    	cout<<"Yes"<<endl;
    }
    int main() {
    	ioio
    	int t = 1;
    	//cin >> t;
    	while (t--) {
    		slove();
    	}
    	return 0;
    }
    
    /*
    
    n*n
    n取偶数
    1111
    1011
    1111
    1110
    
    n取奇数
    
    01111  2
    11111
    11011   2
    11111
    11110   2
    
    2 2 2
    
    
    
    
    */
    
    • 1

    Information

    ID
    6642
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    (None)
    # Submissions
    67
    Accepted
    11
    Uploaded By