当前位置:网站首页>[sliding window] group B of the 9th Landbridge cup provincial tournament: log statistics
[sliding window] group B of the 9th Landbridge cup provincial tournament: log statistics
2022-07-06 21:09:00 【Twilight_ years】

Ideas : The maximum length of the interval is D,id and t After pairing , Sort by time , Maintain the interval with double pointers , The maximum length of this interval shall not exceed D.
cnt[id] Current interval record id Number of occurrences .
st[id] Record id Is it a hot post .
Only the right and left endpoints of the interval need to be maintained .
Reference resources ACWING Pear painted Xiaotang The antithesis of :
AcWing 1238. Log statistics - AcWing

import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
static final int N=100010;
static int n,d,k;
static int[] cnt=new int[N];
static boolean[] st=new boolean[N];
static PII[] logs= new PII[N];
public static void main(String[]args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String[]s=br.readLine().split(" ");
n=Integer.parseInt(s[0]);
d=Integer.parseInt(s[1]);
k=Integer.parseInt(s[2]);
for(int i=0;i<n;i++){
String[]str=br.readLine().split(" ");
int t=Integer.parseInt(str[0]);
int id=Integer.parseInt(str[1]);
logs[i]=new PII(t,id);
}
Arrays.sort(logs,0,n);
for(int i=0,j=0;i<n;i++){
cnt[logs[i].id]++;
while(logs[i].t-logs[j].t>=d){
cnt[logs[j].id]--;
j++;
}
if(cnt[logs[i].id]>=k)st[logs[i].id]=true;
}
for(int i=0;i<N;i++){
if(st[i]==true)System.out.println(i);
}
}
}
class PII implements Comparable<PII>{
int t,id;
public PII(int t,int id){
this.t=t;
this.id=id;
}
public int compareTo(PII o){
return Integer.compare(t,o.t);
}
}
边栏推荐
- 3D人脸重建:从基础知识到识别/重建方法!
- Introduction to the use of SAP Fiori application index tool and SAP Fiori tools
- 数据湖(八):Iceberg数据存储格式
- Leetcode hot topic Hot 100 day 32: "minimum coverage substring"
- [asp.net core] set the format of Web API response data -- formatfilter feature
- How to turn a multi digit number into a digital list
- Reference frame generation based on deep learning
- 性能测试过程和计划
- use. Net analysis Net talent challenge participation
- Performance test process and plan
猜你喜欢

LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件

No Yum source to install SPuG monitoring

Swagger UI tutorial API document artifact

OAI 5g nr+usrp b210 installation and construction

拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条

The mail command is used in combination with the pipeline command statement

968 edit distance

20220211 failure - maximum amount of data supported by mongodb

Introduction to the use of SAP Fiori application index tool and SAP Fiori tools

3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
随机推荐
R語言可視化兩個以上的分類(類別)變量之間的關系、使用vcd包中的Mosaic函數創建馬賽克圖( Mosaic plots)、分別可視化兩個、三個、四個分類變量的關系的馬賽克圖
No Yum source to install SPuG monitoring
2110 summary of knowledge points and common problems in redis class
【滑动窗口】第九届蓝桥杯省赛B组:日志统计
The mail command is used in combination with the pipeline command statement
快过年了,心也懒了
自定义限流注解
Performance test process and plan
966 minimum path sum
审稿人dis整个研究方向已经不仅仅是在审我的稿子了怎么办?
Web开发小妙招:巧用ThreadLocal规避层层传值
PG basics -- Logical Structure Management (transaction)
Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
面试官:Redis中有序集合的内部实现方式是什么?
JS操作dom元素(一)——获取DOM节点的六种方式
Swagger UI教程 API 文档神器
Variable star --- article module (1)
【Redis设计与实现】第一部分 :Redis数据结构和对象 总结
Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍