当前位置:网站首页>牛客小白月賽52--E 分組求對數和(二分)
牛客小白月賽52--E 分組求對數和(二分)
2022-06-25 23:10: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;
}
边栏推荐
- 2022-2028 global selective laser sintering service industry research and trend analysis report
- 元宇宙标准论坛成立
- 剑指 Offer 46. 把数字翻译成字符串(DP)
- 电路模块分析练习5(电源)
- Global and Chinese oleic acid operation mode and market supply and demand forecast report 2022 ~ 2028
- 关闭MongoDB一些服务需要注意的地方(以及开启的相关命令)
- 判断预约时间是否已经过期
- 为什么OpenCV计算的帧率是错误的?
- Use apiccloud AVM multi terminal component to quickly realize the search function in the app
- Flex & Bison 开始
猜你喜欢

2022-2028 global open source cloud storage industry research and trend analysis report

Chapter 3 use of requests Library

2022-2028 global variable frequency compressor technology industry research and trend analysis report

Fastjson反序列化随机性失败

Why is BeanUtils not recommended?

Multi modal data can also be Mae? Berkeley & Google proposed m3ae to conduct Mae on image and text data! The optimal masking rate can reach 75%, significantly higher than 15% of Bert

LM小型可编程控制器软件(基于CoDeSys)笔记十七:pto脉冲功能块

2022-2028 global TFT LCD touch screen industry research and trend analysis report

建立自己的网站(15)
![[eosio] eos/wax signature error is_ Canonical (c): signature is not canonical](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[eosio] eos/wax signature error is_ Canonical (c): signature is not canonical
随机推荐
等价类,边界值,场景法的使用方法和运用场景
Chapter 3 use of requests Library
Privatization lightweight continuous integration deployment scheme -- 03 deployment of Web services (Part 2)
一位博士在华为的22年
C language and the creation and use of database
Canoe: the fifth simulation project: simulation + test
Unity技术手册 - 粒子基础主模块属性-上
2022-2028 global industrial touch screen industry research and trend analysis report
Unity technical manual - particle foundation main module attributes - upper
MySQL数据库索引
This 110 year old "longevity" enterprise has been planning for the next century
剑指 Offer 46. 把数字翻译成字符串(DP)
2022-2028 global DC linear variable differential transformer (LVDT) industry survey and trend analysis report
[eosio] eos/wax signature error is_ Canonical (c): signature is not canonical
ORACLE - 数据查询
The applet draws a simple pie chart
As a programmer, how can we learn, grow and progress happily? (personal perception has nothing to do with technology)
c语言与数据库的创建使用
字符串变形(字符串大小写切换和变现)
异或运算符简单逻辑运算 a^=b