Codeforces Round #532(Div. 2) B.Build a Contest
链接:https://codeforces.com/contest/1100/problem/B
题意:
给n,m。
给m个数,每个数代表一个等级,没给一个将其添加到题目池中,当题目池中有难度(1-n)的题目都存在时,
即可产生一次竞赛。
每给一个数,如果可以出竞赛,输出1,否则输出0。
思路:
一个变量记录有几种题目,一个数组记录每种题目有几个。
能出题时将每种题目的数量减一,减完后为0,则记录种类变量减一。
代码:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+10;
int a[MAXN];
int sum = 0; int main()
{
int n,m,v;
scanf("%d%d",&n,&m);
for (int i = 0;i<m;i++)
{
scanf("%d",&v);
a[v]++;
if (a[v] == 1)
sum++;
if (sum == n)
{
printf("1");
for (int i = 1;i<=n;i++)
{
a[i]--;
if (a[i] == 0)
sum--;
}
}
else
{
printf("0");
}
}
printf("\n"); return 0;
}
Codeforces Round #532(Div. 2) B.Build a Contest的更多相关文章
- 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 #307 (Div. 2) A. GukiZ and Contest
题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...
- Codeforces Round #532 (Div. 2) Solution
A. Roman and Browser 签到. #include <bits/stdc++.h> using namespace std; ]; int get(int b) { ]; ...
- Codeforces Round #532 (Div. 2) F 线性基(新坑) + 贪心 + 离线处理
https://codeforces.com/contest/1100/problem/F 题意 一个有n个数组c[],q次询问,每次询问一个区间的子集最大异或和 题解 单问区间子集最大异或和,线性基 ...
- Codeforces Round #532 (Div. 2):F. Ivan and Burgers(贪心+异或基)
F. Ivan and Burgers 题目链接:https://codeforces.com/contest/1100/problem/F 题意: 给出n个数,然后有多个询问,每次回答询问所给出的区 ...
- Codeforces Round #532 (Div. 2)- B(思维)
Arkady coordinates rounds on some not really famous competitive programming platform. Each round fea ...
- Codeforces Round #532(Div. 2) C.NN and the Optical IIIusion
链接:https://codeforces.com/contest/1100/problem/C 题意: 一个圆球外面由其他圆球包裹,两两相连. 给出n,r. n为外面圆球数量,r为内部圆球半径. 求 ...
- Codeforces Round #532(Div. 2) A.Roman and Browser
链接:https://codeforces.com/contest/1100/problem/A 题意: 给定n,k. 给定一串由正负1组成的数. 任选b,c = b + i*k(i为任意整数).将c ...
随机推荐
- [haoi2015]T1
题意:给定你一颗树,要求你在这棵树中确定K个黑点和N-K个白点,使黑点间与白点间两两距离之和最大,输出最大值.n<=2000 对于这道题,我想了好几个思路,包括点分治,贪心,动规,网络流等等,实 ...
- Block和inline元素对比
所有的HTML元素都属于block和inline之一.block元素的特点是:总是在新行上开始:高度,行高以及顶和底边距都可控制:宽度缺省是它的容器的100%,除非设定一个宽度<div>, ...
- jquery特效(3)—轮播图①(手动点击轮播)
写了一个轮播图练练手,先写了一个手动点击轮播的轮播图,随后我会慢慢接着深入写自动轮播图和鼠标悬浮图片停止移动轮播图等,虽然今天我生日,但是代码还是得写的,不能找借口放松自己,原地踏步也算后退. 下面来 ...
- Appium——WebDriverException: Message: A new session could not be created.
每次启动完一次脚本再次启动的时候会报这个错误,会话没有被创建 查看了下Appium日志: 查看下设备是否准备好,我用的是模拟器,就cmd下查看下设备: 可以看到设备掉线了... 好吧,重启下设备 脚本 ...
- <ZZ>Linux rpm 命令参数使用详解[介绍和应用]
http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/10/08/2203153.html RPM是RedHat Package Manager ...
- BluetoothLE-Multi-Library 一个能够连接多台蓝牙设备的库,它可以作为client端,也可以为server端。支持主机/从机,外围设备连接。
github地址:https://github.com/qindachang/BluetoothLE-Multi-Library BluetoothLE-Multi-Library 一个能够连接多台蓝 ...
- insert插入错误
16:24:30,803 Fetching JDBC Connection from DataSource 16:24:30,826 Returning JDBC Connection to Data ...
- Flutter实战视频-移动电商-62.购物车_首页Provide化 让跳转随心所欲
62.购物车_首页Provide化 让跳转随心所欲 新建provide/currentIndex.dart 内容比较简单,定义一个变量当前页面的索引currentIndex,再定义一个方法改变它的值 ...
- HDU 2586 How far away ? (LCA,Tarjan, spfa)
题意:给定N个节点一棵树,现在要求询问任意两点之间的简单路径的距离,其实也就是最短路径距离. 析:用LCA问题的Tarjan算法,利用并查集的优越性,产生把所有的点都储存下来,然后把所有的询问也储存下 ...
- jQuery 学习笔记(一)jQuery 语法
jQuery 是一个 JavaScript 库,极大地简化了 JavaScript 编程,很容易学习 添加 jQuery 库 <head> <script type="te ...