Home  >  Article  >  Database  >  ZOJ 3787 Access System

ZOJ 3787 Access System

WBOY
WBOYOriginal
2016-06-07 15:49:071175browse

ZOJ 3787 Access System 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3787 2014 第十一届浙江省赛 L 题目大意:进门系统模拟。进宿舍门要刷身份卡,但是有人刷卡进了门,L秒之内想进的人就不需要刷了,大家都很懒,能不刷就不

ZOJ   3787   Access System

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3787

2014 第十一届浙江省赛 L

题目大意:进门系统模拟。进宿舍门要刷身份卡,但是有人刷卡进了门,L秒之内想进的人就不需要刷了,大家都很懒,能不刷就不刷。给出n个人的到来时间(无序),和刷卡后门会保持开启状态的时间,问哪些人需要刷卡(按给出的顺序算)。

题目分析:结构体存,时间存在一个整数里,另外就是记录给出时的编号和是否需要刷卡的布尔变量。按到来时间排序后顺着刷一遍,得到每个人是否需要刷卡的结果(注意无论如何第一个人是要刷的),然后再按给出顺序排回来输出。

code:

#include
#include
using namespace std;
struct stu
{
    int time,num;
    bool need;
}a[20010];
bool cmp1(stu a,stu b)
{
    return a.time=j+l)
            {
                a[i].need=true;
                j=a[i].time;
                sum++;
            }
            else a[i].need=false;
        }
        sort(a,a+n,cmp2);
        printf("%d\n",sum--);
        for(i=0;i
PS:1A




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn