当前位置:网站首页>The sum of logarithms in group 52--e of Niuke Xiaobai monthly race (two points)

The sum of logarithms in group 52--e of Niuke Xiaobai monthly race (two points)

2022-06-25 23:10:00 Rong AI holiday

E Sum logarithms in groups

Topic ideas

Ideas : Find two numbers greater than... From all the numbers k The number of schemes minus two numbers found from one person is greater than k Is the answer

Title code

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int N=1e6+10;
const ll INF=2000000000;
const int mod=998244353;
int n,k;
vector<int> g[N],h;
int cal(vector<int>&s){
    
    sort(s.begin(),s.end());
    int ans=0;
    for(int i=0;i<s.size();i++){
    
       int res=lower_bound(s.begin()+i+1,s.end(),k-s[i])-s.begin();
       res=s.size()-res+1;
       ans+=res;
       ans%=mod;
    }
    return ans;
}
int main(){
    
    cin>>n>>k;
    for(int i=1;i<=n;i++){
    
        int s;
        cin>>s;
        for(int j=1;j<=s;j++){
    
            int x;
            cin>>x;
            g[i].push_back(x);
            h.push_back(x);
        }
    }
    int ans=0;
    ans=cal(h);
    for(int i=1;i<=n;i++){
    
        ans=(ans-cal(g[i])+mod)%mod;
    }
    cout<<ans;
    return 0;
}

原网站

版权声明
本文为[Rong AI holiday]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251938289404.html