当前位置:网站首页>牛客小白月赛52--E 分组求对数和(二分)
牛客小白月赛52--E 分组求对数和(二分)
2022-06-25 21:57:00 【容艾假】
E 分组求对数和
题目思路
思路:从所有的数中找出两个大于k的数字的方案数减去从一个人那里找出的两个数大于k的方案即为答案
题目代码
#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;
}
边栏推荐
- MySQL数据库索引
- Mysql database index
- Openwrt (VIII) application layer development
- Oracle - getting started
- Huawei cloud SRE deterministic operation and maintenance special issue (the first issue)
- ES6 -- formal parameter setting initial value, extension operator, iterator, and generating function
- What do l and R of earphone mean?
- New network security competition of the secondary vocational group in 2022
- 2022-2028 global carbon fiber unidirectional tape industry research and trend analysis report
- oracle -- 表操作
猜你喜欢
ES6-Const常量与数组解构
一位博士在华为的22年
Use apiccloud AVM multi terminal component to quickly realize the search function in the app
ES6 --- 数值扩展、对象拓展
1281_ FreeRTOS_ Implementation analysis of vtaskdelayuntil
ES6 - numerical extension and object extension
Oracle - 基本入门
2、一个向量乘它的转置,其几何意义是什么?
万亿热钱砸向太空经济,真的是一门好生意?
NRM source switching tool
随机推荐
2022-2028 global carbon fiber unidirectional tape industry research and trend analysis report
ES6 --- 数值扩展、对象拓展
2022-2028 global SiC igniter industry research and trend analysis report
Travel notes of 2022giao
Use of local stack in flask
Unity的Ping類使用
Eureka core ⼼ source code analysis
Three layer architecture + routing experiment
Why is BeanUtils not recommended?
What are the channels for Internet advertising to gain customers?
Unity技术手册 - GetKey和GetAxis和GetButton
Facing the "industry, University and research" gap in AI talent training, how can shengteng AI enrich the black land of industrial talents?
等价类,边界值,场景法的使用方法和运用场景
Canoe: the fifth simulation project: simulation + test
2022-2028 global cloud based remote browser isolation industry research and trend analysis report
MATLAB Programming Notes
ES6-- 模板字符串、对象的简化写法、箭头函数
2022-2028 global variable frequency compressor technology industry research and trend analysis report
Simple and easy-to-use cache library gcache
Unity技术手册 - 粒子基础主模块属性-上