Build a Contest-创建比赛 CodeForce1100B

题目链接:Build a Contest

题目原文

  Arkady coordinates rounds on some not really famous competitive programming platform. Each round features ? problems of distinct difficulty, the difficulties are numbered from 1 to ?.

  To hold a round Arkady needs ? 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 1 to ? and puts it into the problems pool.

  At each moment when Arkady can choose a set of ?n 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.

题目大意

阿尔卡迪管理着一个程序竞赛平台。每个题目的难度都会被分成1-n,n个等级。每次创建比赛的时候需要难度为1-n的试题。每次出题都会把题目放入题库中,已知一个阿尔卡迪每次出题难度的序列,在阿尔卡迪能够创建一场比赛的时候输出1.

思路

用一个数组来存剩余的每种难度的题目的数量,如果1-n全不为0,就说明可以开contest了。然后把所有元素都减去1。

题解

 1 #include <iostream>
 2 #include <cstring>
 3 
 4 int level, num, tmp, flg;
 5 int vis[100005];
 6 
 7 using namespace std;
 8 
 9 int main(int argc, char const *argv[])
10 {
11     cin >> level >> num;
12     flg = level;    //记录缺几种难度的题目
13     for(int i = 0; i < num; i++)
14     {
15         cin >> tmp;
16         if (vis[tmp]++ == 0)    //之前没有出现过难度为i的题目
17         {
18             flg--;
19         }
20         if(flg == 0)            //题库里有所有难度的题目
21         {
22             cout << 1;
23             flg = level;
24             for(int j = 1; j <= level; j++)
25             {
26                 vis[j]--;
27                 if (vis[j] > 0) 
28                 {
29                     flg--;
30                 }
31             }
32         }
33         else
34         {
35             cout << 0;
36         }
37     }
38     return 0;
39 }

 

转载于:https://www.cnblogs.com/SaltyFishQF/p/10392898.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值