当前位置:网站首页>Niuke Xiaobai monthly race 52 E. sum logarithms in groups (two points & inclusion and exclusion)
Niuke Xiaobai monthly race 52 E. sum logarithms in groups (two points & inclusion and exclusion)
2022-07-07 06:18:00 【Harris-H】
Niuke Xiaobai moon race 52 E. Sum logarithms in groups ( Two points & A class )
First save all the numbers in an array , Then use two dimensions vector Save the number of each group .
According to the thought of tolerance and exclusion , For each number, first find all the satisfied numbers by dichotomy, and then subtract the number in your group .
Those in my group are corresponding vector Two points in .
Time complexity : O ( m l o g m ) O(mlogm) O(mlogm)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n, k;
vector<int> ve[1000009], a;
void solved() {
scanf("%d%d", &n, &k);
int m;
for(int i = 0; i < n; i ++) {
scanf("%d", &m);
int x;
while(m --) {
scanf("%d", &x);
ve[i].push_back(x);
a.push_back(x);
}
sort(ve[i].begin(), ve[i].end());
}
sort(a.begin(), a.end());
ll ans = 0;
for(int i = 0; i < n; i ++) {
m = ve[i].size();
for(int j = 0; j < m; j ++) {
int x = ve[i][j], y = k - x;
ans +=
(a.end() - upper_bound(a.begin(), a.end(), y - 1)) -
(ve[i].end() - upper_bound(ve[i].begin(), ve[i].end(), y - 1));
}
}
ans /= 2;
cout << ans % 998244353;
}
int main() {
// int ttx; cin >> ttx; while(ttx --)
solved();
return 0;
}
边栏推荐
- vim映射大K
- JVM命令之 jstack:打印JVM中线程快照
- 搞懂fastjson 对泛型的反序列化原理
- Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
- Oracle迁移中关于大容量表使用数据泵(expdp、impdp)导出导入容易出现的问题和注意事项
- JVM命令之 jinfo:实时查看和修改JVM配置参数
- ST表预处理时的数组证明
- Party A's requirements for those who have lost 800 yuan
- 测试开发基础,教你做一个完整功能的Web平台之环境准备
- 如果不知道这4种缓存模式,敢说懂缓存吗?
猜你喜欢
Check Point:企业部署零信任网络(ZTNA)的核心要素
window下面如何安装swoole
基于FPGA的VGA协议实现
jmeter 函数助手 — — 随机值、随机字符串、 固定值随机提取
Ideas of high concurrency and high traffic seckill scheme
进程间通信之共享内存
693. Travel sequencing
Career experience feedback to novice programmers
你不知道的互联网公司招聘黑话大全
postgresql 数据库 timescaledb 函数time_bucket_gapfill()报错解决及更换 license
随机推荐
JVM命令之 jstack:打印JVM中线程快照
Personal imitation SSM framework
693. 行程排序
Go language learning notes - Gorm use - Gorm processing errors | web framework gin (10)
Change the original style of UI components
C. colonne Swapping [tri + Simulation]
【FPGA教程案例14】基于vivado核的FIR滤波器设计与实现
cf:C. Column Swapping【排序 + 模擬】
jvm命令之 jcmd:多功能命令行
如何在Touch Designer 2022版中设置解决Leap Motion不识别的问题?
Talking about reading excel with POI
MFC BMP sets the resolution of bitmap, DPI is 600 points, and gdiplus generates labels
You don't know the complete collection of recruitment slang of Internet companies
postgresql 数据库 timescaledb 函数time_bucket_gapfill()报错解决及更换 license
SubGHz, LoRaWAN, NB-IoT, 物联网
PTA ladder game exercise set l2-004 search tree judgment
window下面如何安装swoole
绕过open_basedir
ETCD数据库源码分析——从raftNode的start函数说起
Sequential storage of stacks