当前位置:网站首页>Public key box
Public key box
2022-07-06 14:53:00 【< WRM>】
#include<bits/stdc++.h>
using namespace std;
const int N = 10010;
struct node {
int id;
int type;
int time;
} a[N];
int q[N];
bool compare(node x, node y) {
if (x.time != y.time) return x.time < y.time;
if (x.type != y.type) return x.type > y.type;
if (x.id != y.id) return x.id < y.id;
}
int main() {
int n, k;
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; i++) {
q[i] = i;
}
int pos = 0;
while (k--) {
int id, start, length;
scanf("%d%d%d", &id, &start, &length);
a[pos++] = {
id, 0, start}; // Take the key
a[pos++] = {
id, 1, start + length}; // Change the key
}
sort(a, a + pos,compare);
for (int i = 0; i < pos; i++) {
if (a[i].type == 0) {
for (int j = 1; j <= n; j++) {
if (a[i].id == q[j]) {
q[j] = 0;
break;
}
}
} else {
for (int j = 1; j <= n; j++) {
if (!q[j]) {
q[j] = a[i].id;
break;
}
}
}
}
for(int i=1;i<=n;i++) printf("%d ",q[i]);
return 0;
}
边栏推荐
- Cc36 different subsequences
- Why can swing implement a form program by inheriting the JFrame class?
- 函数:求1-1/2+1/3-1/4+1/5-1/6+1/7-…+1/n
- How to earn the first pot of gold in CSDN (we are all creators)
- 指针:最大值、最小值和平均值
- The four connection methods of JDBC are directly coded
- 王爽汇编语言学习详细笔记一:基础知识
- Transplant hummingbird e203 core to Da Vinci pro35t [Jichuang xinlai risc-v Cup] (I)
- How to transform functional testing into automated testing?
- Logstack introduction and deployment -- elasticstack (elk) work notes 019
猜你喜欢
About the garbled code problem of superstar script
Binary search tree concept
Fundamentals of digital circuits (I) number system and code system
Markdown font color editing teaching
Wang Shuang's detailed notes on assembly language learning I: basic knowledge
关于交换a和b的值的四种方法
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。
Soft exam information system project manager_ Project set project portfolio management --- Senior Information System Project Manager of soft exam 025
“Hello IC World”
随机推荐
Wang Shuang's detailed learning notes of assembly language II: registers
【指针】求解最后留下的人
Lintcode logo queries the two nearest saplings
JDBC 的四种连接方式 直接上代码
ES全文索引
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
数字电路基础(一)数制与码制
Solutions to common problems in database development such as MySQL
Functions: Finding Roots of equations
. Net6: develop modern 3D industrial software based on WPF (2)
What is an index in MySQL? What kinds of indexes are commonly used? Under what circumstances will the index fail?
MySQL learning notes (stage 1)
How to transform functional testing into automated testing?
Detailed introduction to dynamic programming (with examples)
JVM memory model concept
Wu Enda's latest interview! Data centric reasons
5 minutes to master machine learning iris logical regression classification
Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class
【指针】删除字符串s中的所有空格
数字电路基础(五)算术运算电路