当前位置:网站首页>牛客小白月赛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;
}
边栏推荐
- 多模态数据也能进行MAE?伯克利&谷歌提出M3AE,在图像和文本数据上进行MAE!最优掩蔽率可达75%,显著高于BERT的15%...
- 2022-2028 global open source cloud storage industry research and trend analysis report
- Fastjson deserialization randomness failed
- 2022年中职组网络安全新赛题
- Eureka core ⼼ source code analysis
- 2022-2028 global variable frequency compressor technology industry research and trend analysis report
- What is 5g? What can 5g do? What will 5g bring in the future?
- 2022-2028 global co extrusion production line industry research and trend analysis report
- Pit resolution encountered using East OCR (compile LAMS)
- Lecture 14 of the Blue Bridge Cup -- number theory [exercises]
猜你喜欢

小程序绘制一个简单的饼图

Wpewebkit debugging MSE playback

Nacos source code analysis 01 code structure

Which PHP open source works deserve attention

2022-2028 global web and browser isolation platform industry research and trend analysis report

ES7/ES9 -- 新特性与正则

QT learning setting executable exe attribute (solving the problem of Chinese attribute garbled)

Use of local stack in flask

Utilisation de la classe Ping d'Unity

Programmer weekly (issue 4): the wealth view of programmers
随机推荐
Network security project questions of the first Henan vocational skills competition in 2022
Does jQuery cache any selectors- Does jQuery do any kind of caching of “selectors”?
Analysis report on demand and investment forecast of global and Chinese flame retardant hydraulic oil market from 2022 to 2028
[eosio] eos/wax signature error is_ Canonical (c): signature is not canonical
Obsidian basic tutorial
2022-2028 global RBI platform industry research and trend analysis report
Programmer weekly (issue 4): the wealth view of programmers
Huawei cloud SMS has tested that many mobile phones prompt frequent sending
Reasons why MySQL cannot be connected externally after installing MySQL database on ECs and Solutions
Unity技术手册 - 粒子基础主模块属性-上
Cvpr2022 tutorial | machine learning remote sensing processing: agriculture and food security, University of Maryland
How to open a futures account safely at present? Which futures companies are more reliable?
Wpewebkit debugging MSE playback
Privatization lightweight continuous integration deployment scheme -- 03 deployment of Web services (Part 2)
华为云SRE确定性运维专刊(第一期)
Oracle - getting started
最近准备翻译外国优质文章
22 years of a doctor in Huawei
[WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF
ORACLE - 数据查询