# 14240: 【原4240】简单序列

### 题目描述

author: kstarxin 原OJ链接：https://acm.sjtu.edu.cn/OnlineJudge-old/problem/4240

# 简单序列

## 数据规模

$$0 < s \leq 2000000$$
$$0 < p \leq 1000000$$
$$0 \leq |a_n| \leq 2000000$$

## 样例输入

5
5 4 3 2 1
2
0 5
1 6


## 样例输出

1 2 3 4 6


## q4x3's solution

/**
* 桶排序
* 一个O(n)为什么要卡常
* 枯了TAT
* 又知道了一大堆优化方法，真好，就是头冷
**/
#include <iostream>
#include <stdio.h>
#define re register
#define maxm 2000233
using namespace std;

x = 0;
char ch;
bool f = 0;
while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
if (ch == '-') f = 1;
else x = ch - '0';
while(ch = getchar(), ch >= '0' && ch <= '9') x = 10 * x + ch - '0';
x = f ? -x : x;
}

bool num[4002333];

int main() {
int s;
int p;
re int tmp1;
re int tmp2;
re int tmp;
re int tmpp;
re int maxi(-123456789);
re int mini(123456789);
for(re int i = 0;i < s;++ i) {
tmpp = tmp + maxm;
num[tmpp] = 1;
if(tmpp > maxi) maxi = tmpp;
if(tmpp < mini) mini = tmpp;
}
for(re int i = 0;i < p;++ i) {
tmpp = tmp2 + maxm;
if(tmp1 == 1) {
num[tmpp] = 1;
if(tmpp > maxi) maxi = tmpp;
if(tmpp < mini) mini = tmpp;
} else {
num[tmpp] = 0;
}
}
for(re int i = mini;i <= maxi;++ i) {
if(num[i])
printf("%d ", i - maxm);
}
}


## victrid's solution

#include <cstdio>
#include <iostream>
using namespace std;
//barrel sort
//assume no duplicat.
bool barrel[4000010]  = {0};
// int barrelblock[4001] = {0};
int main() {
int n, proc;
scanf("%d", &n);
while (n--) {
scanf("%d", &proc);
barrel[2000005 + proc] = 1;
/* ++barrelblock[(2000005 + proc) / 1000]; */
}
scanf("%d", &n);
while (n--) {
scanf("%d", &proc);
if (proc) {
scanf("%d", &proc);
barrel[2000005 + proc] = 1;
// ++barrelblock[(2000005 + proc) / 1000];
} else {
scanf("%d", &proc);
barrel[2000005 + proc] = 0;
// --barrelblock[(2000005 + proc) / 1000];
}
}
// for (int blk = 0; blk < 4000; blk++) {
for (int i = 1 /* blk * 1000 */; /* barrelblock[blk] && */ i < 4000010; i++) {
if (barrel[i]) {
printf("%d ", (i - 2000005));
// barrelblock[blk]--;
}
}
/* } */
return 0;
}


## yyong119's solution

#include <cstdio>
using namespace std;
#define MAX_AN 4000100
#define ZERO 2000005

int a[MAX_AN];
int s, p, tmp;

int p, data = 0;
char ch = 0;
while ((ch != '-') && ch < '0' || ch > '9') ch = getchar();
if (ch=='-') {
p = -1;
ch = getchar();
} else p = 1;
while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();
return data * p;
}

int main() {

scanf("%d", &s);
for (int i = 0; i < s; ++i) {
// scanf("%d", &tmp);
a[tmp + ZERO] = 1;
}

scanf("%d", &p);
while (p--) {
int op, num;
// scanf("%d%d", &op, &num);
a[num + ZERO] = op;
}

for (int i = 0; i < MAX_AN; ++i)
if (a[i])
printf("%d ", i - ZERO);
return 0;
}


## zqy2018's solution

#include <cstdio>
#define INF 2000000000
using namespace std;
typedef long long ll;
int f = 1, x = 0;
char c = getchar();
while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
return f * x;
}
int n, m;
bool cnt[4000005] = {0};
void init(){
scanf("%d", &n);
for (int i = 0; i < n; ++i){
cnt[t + 2000000] = true;
}
}
void solve(){
scanf("%d", &m);
for (int i = 0; i < m; ++i){