当前位置:网站首页>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;
}
边栏推荐
- Intranet information collection of Intranet penetration (3)
- 【指针】求解最后留下的人
- [pointer] the array is stored in reverse order and output
- 数字电路基础(四) 数据分配器、数据选择器和数值比较器
- Fundamentals of digital circuits (II) logic algebra
- Proceedingjoinpoint API use
- Statistics 8th Edition Jia Junping Chapter 2 after class exercises and answer summary
- “人生若只如初见”——RISC-V
- Function: find the maximum common divisor and the minimum common multiple of two positive numbers
- Function: find the root of the equation by Newton iterative method
猜你喜欢
《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
内网渗透之内网信息收集(三)
《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案
Markdown font color editing teaching
Résumé des points de connaissance et des réponses aux exercices après la classe du chapitre 7 de Jia junping dans la huitième édition des statistiques
Fundamentals of digital circuits (I) number system and code system
Statistics 8th Edition Jia Junping Chapter 5 probability and probability distribution
[Ogg III] daily operation and maintenance: clean up archive logs, register Ogg process services, and regularly back up databases
线程的实现方式总结
1.支付系统
随机推荐
JVM memory model concept
{1,2,3,2,5} duplicate checking problem
Pointeurs: maximum, minimum et moyenne
. Net6: develop modern 3D industrial software based on WPF (2)
Sentinel overall workflow
[pointer] find the value of the largest element in the two-dimensional array
[pointer] use the insertion sorting method to arrange n numbers from small to large
《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案
5分钟掌握机器学习鸢尾花逻辑回归分类
{1,2,3,2,5}查重问题
[pointer] counts the number of times one string appears in another string
线程的实现方式总结
Database monitoring SQL execution
Binary search tree concept
Express
Get started with Matplotlib drawing
My first blog
内网渗透之内网信息收集(三)
Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?
How to transform functional testing into automated testing?