当前位置:网站首页>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;
}
边栏推荐
- yarn入门(一篇就够了)
- Red hat install kernel header file
- Rk3399 platform development series explanation (interruption) 13.10, workqueue work queue
- 693. 行程排序
- 3531. 哈夫曼树
- 【FPGA教程案例13】基于vivado核的CIC滤波器设计与实现
- 360 Zhiyu released 7.0 new products to create an exclusive "unified digital workspace" for the party, government and army, and central and state-owned enterprises
- Ideas of high concurrency and high traffic seckill scheme
- Test the foundation of development, and teach you to prepare for a fully functional web platform environment
- The boss always asks me about my progress. Don't you trust me? (what do you think)
猜你喜欢
POI excel export, one of my template methods
老板总问我进展,是不信任我吗?(你觉得呢)
Go语学习笔记 - gorm使用 - 原生sql、命名参数、Rows、ToSQL | Web框架Gin(九)
Detailed explanation of platform device driver architecture in driver development
Bbox regression loss function in target detection -l2, smooth L1, IOU, giou, Diou, ciou, focal eiou, alpha IOU, Siou
生活中的开销,怎么记账合适
开发者别错过!飞桨黑客马拉松第三期链桨赛道报名开启
The boss always asks me about my progress. Don't you trust me? (what do you think)
JVM命令之 jstack:打印JVM中线程快照
Check Point:企业部署零信任网络(ZTNA)的核心要素
随机推荐
laravel 使用腾讯云 COS5全教程
MySQL performance_ Schema common performance diagnosis query
Experience of Niuke SQL
Peripheral driver library development notes 43: GPIO simulation SPI driver
Jcmd of JVM command: multifunctional command line
JVM command - jmap: export memory image file & memory usage
Vscode for code completion
CTFshow--常用姿势
高并发大流量秒杀方案思路
Oracle迁移中关于大容量表使用数据泵(expdp、impdp)导出导入容易出现的问题和注意事项
Introduction to yarn (one article is enough)
Subghz, lorawan, Nb IOT, Internet of things
Jstack of JVM command: print thread snapshots in JVM
Jmeter自带函数不够用?不如自己动手开发一个
10W word segmentation searches per second, the product manager raised another demand!!! (Collection)
C note 13
Solve pod install error: FFI is an incompatible architecture
Laravel uses Tencent cloud cos5 full tutorial
3531. 哈夫曼树
JVM命令之 jstat:查看JVM統計信息