Codeforces Round #532 (Div. 2)- B(思维)
Arkady coordinates rounds on some not really famous competitive programming platform. Each round features nn problems of distinct difficulty, the difficulties are numbered from 11 to nn.
To hold a round Arkady needs nn new (not used previously) problems, one for each difficulty. As for now, Arkady creates all the problems himself, but unfortunately, he can't just create a problem of a desired difficulty. Instead, when he creates a problem, he evaluates its difficulty from 11 to nn and puts it into the problems pool.
At each moment when Arkady can choose a set of nn new problems of distinct difficulties from the pool, he holds a round with these problems and removes them from the pool. Arkady always creates one problem at a time, so if he can hold a round after creating a problem, he immediately does it.
You are given a sequence of problems' difficulties in the order Arkady created them. For each problem, determine whether Arkady held the round right after creating this problem, or not. Initially the problems pool is empty.
Input
The first line contains two integers nn and mm (1≤n,m≤1051≤n,m≤105) — the number of difficulty levels and the number of problems Arkady created.
The second line contains mm integers a1,a2,…,ama1,a2,…,am (1≤ai≤n1≤ai≤n) — the problems' difficulties in the order Arkady created them.
Output
Print a line containing mm digits. The ii-th digit should be 11 if Arkady held the round after creation of the ii-th problem, and 00 otherwise.
Examples
input
Copy
3 11
2 3 1 2 2 2 3 2 2 3 1
output
Copy
00100000001
input
Copy
4 8
4 1 3 3 2 3 3 3
output
Copy
00001000
Note
In the first example Arkady held the round after the first three problems, because they are of distinct difficulties, and then only after the last problem.
思路:一开始理解错题意了,以前剩下的题目也要算在后边,故可以用标记数组的量来检测
代码:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int vis[100005],a[100005];
int main()
{
int n,m;
cin>>n>>m;
int sum=0;
for(int t=0;t<m;t++)
{
scanf("%d",&a[t]);
if(vis[a[t]]==0)
{
sum++;
}
vis[a[t]]++;
if(sum==n)
{
printf("1");
sum=0;
for(int j=1;j<=n;j++)
{
vis[j]--;
if(vis[j]>0)
{
sum++;
}
}
}
else if(sum<n)
{
printf("0");
}
}
return 0;
}
Codeforces Round #532 (Div. 2)- B(思维)的更多相关文章
- Codeforces Round #532 (Div. 2)
Codeforces Round #532 (Div. 2) A - Roman and Browser #include<bits/stdc++.h> #include<iostr ...
- Codeforces Round #532 (Div. 2) 题解
Codeforces Round #532 (Div. 2) 题目总链接:https://codeforces.com/contest/1100 A. Roman and Browser 题意: 给出 ...
- Codeforces Round #532 (Div. 2)- A(思维)
This morning, Roman woke up and opened the browser with nn opened tabs numbered from 11 to nn. There ...
- 【CF1256】Codeforces Round #598 (Div. 3) 【思维+贪心+DP】
https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价 ...
- Codeforces Round #143 (Div. 2) (ABCD 思维场)
题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...
- Codeforces Round #395 (Div. 2)(A.思维,B,水)
A. Taymyr is calling you time limit per test:1 second memory limit per test:256 megabytes input:stan ...
- Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)
A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- Codeforces Round #532 (Div. 2) F 线性基(新坑) + 贪心 + 离线处理
https://codeforces.com/contest/1100/problem/F 题意 一个有n个数组c[],q次询问,每次询问一个区间的子集最大异或和 题解 单问区间子集最大异或和,线性基 ...
- Codeforces Round #533 (Div. 2) C.思维dp D. 多源BFS
题目链接:https://codeforces.com/contest/1105 C. Ayoub and Lost Array 题目大意:一个长度为n的数组,数组的元素都在[L,R]之间,并且数组全 ...
随机推荐
- Codeforces 1142D(dp)
题目传送 先给出设计dp的结论: dp[i][j]:以第i个位置.以rankj的数拓展出去的方案数.意会一下,我实在想不好语言-- 其中所谓rankj=真·rank%11 找到拓展的规律,转移也就顺理 ...
- ROS Learning-016 Arduino-For-ROS-001 搭建 Arduino 和 ROS 之间相连接的开发环境
Arduino For ROS-001 - 搭建 ROS 和 Arduino 相连接的开发环境 我的Ubuntu系统:Ubuntu 14.04.10 TLS 32位 Arduino的版本:Arduin ...
- loj10087 Intervals
传送门 分析 我们设S[i]表示到第i个数为止一共有多少个数在集合Z之中,最终答案就是S[max]-S[min]的最小值.所以我们不难发现对于每一个[ai,bi]都表示S[bi]-S[ai-1]> ...
- windows平台下用C#访问HBase
Hadoop中的HBase有多种数据访问方式,ubuntu里可以用hbase shell查看操作hbase数据库,但windows平台下需要用thrift对它进行访问. 例如hadoop安装在/usr ...
- Umbraco Form 中需要为一个Form的某个field设置特别的CSS样式
在项目开发中,我有一个需求,需要建立一个页面,这个页面上有一个form, 这个form上有一个checkbox, 就是普通的接受terms & conditions, 类似下图 这个项目中的U ...
- register的功能
register:这个关键字请求编译器尽可能 的将变量存在CPU内部寄存器中,而不是通过内存寻址访问,以提高效率.这里注意是尽可能,不是绝对.你想想,一个CPU拥有 的寄存器也就那么几个或几十个,你要 ...
- hadoop streaming 文档
Hadoop Streaming框架使用(一) Streaming简介 Streaming框架允许任何程序语言实现的程序在Hadoop MapReduce中使用,方便已有程序向Hadoop平台移植.因 ...
- 自己写的Log记录组件
常规的Debug组件的封装,然后加了一个文件log,分异步和同步(可跨平台使用). /// <summary> /// 常用IO操作类 /// </summary> publi ...
- c#继承、多重继承
c#类 1.c#类的继承 在现有类(基类.父类)上建立新类(派生类.子类)的处理过程称为继承.派生类能自动获得基类的除了构造函数和析构函数以外的所有成员,可以在派生类中添加新的属性和方法扩展其功能.继 ...
- sqlserver清楚文本中的换行符
REPLACE(@string,CHAR(13)+CHAR(10),char(32))