[暴力]JZOJ 5891 巡逻

Description

 

Input

Output

 

Sample Input

7 4
6
4
2
1

Sample Output

3
5
6
4
2
1
7
 

Data Constraint

分析

水题不解释

 

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=1e5+10;
int a[N],b[N],at,bt;
int n,m;

int main() {
    freopen("patrol.in","r",stdin);
    freopen("patrol.out","w",stdout);
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) a[i]=i;
    for (int i=1;i<=m;i++) {
        scanf("%d",&b[i]);
        a[b[i]]=2147483647;
    }
    sort(a+1,a+n+1);
    at=1;bt=1;
    for (int i=1;i<=n;i++) {
        while (a[at]>b[bt]&&bt<=m) {
            printf("%d\n",b[bt]);
            bt++;i++;
        }
        if (i>n) break;
        printf("%d\n",a[at]);
        at++;
    }
    fclose(stdin);fclose(stdout);
}
View Code

 

posted @ 2018-10-14 20:41  Vagari  阅读(137)  评论(0编辑  收藏  举报