题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=168

分析:找到一天中需要最多的房间即可

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define N 200

int day[N];//day[i] 第i天的最多房间数 

int main()
{
    freopen("d:\\in.txt", "r", stdin);
    int t, n;
    scanf("%d", &t);
    while(t--){
        memset(day, , sizeof(day));
        scanf("%d", &n);
        int num, start, length;
        ; i<n; i++){
            scanf("%d%d%d", &num, &start, &length);
            ; i<length; i++){
                day[i+start] += num;
            }
        }
        ;
        ; i<N; i++){
            ans = max(ans, day[i]);
        }
        printf("%d\n", ans);
    } 

    ;
}

看别人题解后才明白的,同时记录下自己的模拟算法(TimeLimitExceeded)

 #include<iostream>
 #include<cstdio>
 #include<cstring>
 #include<string>
 #include<algorithm>
 #include<cmath>
 using namespace std;
 #define INPUT freopen("d:\\in.txt", "r", stdin);
 #define N 10002 

 struct Node {
     int a, b, v;
 }c[N];

 bool cmp(Node n1, Node n2)
 {
     return n1.a != n2.a ? n1.a < n2.a : n1.b < n2.b;
 }
 int main()
 {
     INPUT;

     int t, n;
     scanf("%d", &t);
     while(t--)
     {
         scanf("%d", &n);
         int day;
         ; i<n; i++){
             scanf("%d%d%d", &c[i].v, &c[i].a, &day);
             c[i].b = c[i].a+day;
         }
         sort(c, c+n, cmp);
         ].v;
         ; i<n; i++){
             int cur = c[i].v;
             ans += cur;
             ; j<i; j++){
                 if(c[j].v && cur && c[j].b <= c[i].a){//如果 j团有剩余房间 且 当前订单还需要房间 且j团已离开
                     int reuse = min(c[j].v, cur);
                     ans -= reuse;
                     c[j].v -= reuse;
                     cur -= reuse;
                 }
             }
         }
         printf("%d\n", ans);
     }
     ;
 }

[河南省ACM省赛-第三届] 房间安排 (nyoj 168)的更多相关文章

  1. [河南省ACM省赛-第三届] 素数 (nyoj 169)

    #include <iostream> #include <cstdio> #include <queue> #include <cstring> #i ...

  2. [河南省ACM省赛-第三届] AMAZING AUCTION (nyoj 251)

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=251 规则: 1.若某竞标价唯一,则胜出 2.若不存在唯一竞标价,则投标次数最少竞标价中标 ...

  3. [河南省ACM省赛-第三届] 网络的可靠性 (nyoj 170)

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=170 根据题意,需要找到度数为1的结点个数,如下图: #include<iostre ...

  4. [河南省ACM省赛-第三届] 聪明的kk (nyoj 171)

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=171 动态规划: d(i,j) = max{d(i-1, j), d(i, j-1)}+m ...

  5. [河南省ACM省赛-第三届] BUYING FEED (nyoj 248)

    #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> us ...

  6. [河南省ACM省赛-第四届] 序号互换 (nyoj 303)

    相似与27进制的转换 #include<iostream> #include<cstdio> #include<cstring> #include<strin ...

  7. [河南省ACM省赛-第四届] 表达式求值(nyoj 305)

    栈的模拟应用: #include<iostream> #include<cstdio> #include<cstring> #include<string&g ...

  8. Mine Number(搜索,暴力) ACM省赛第三届 G

    Mine Number Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Every one once played the gam ...

  9. ACM 房间安排

    房间安排 时间限制:3000 ms  |  内存限制:65535 KB 难度:2   描述 2010年上海世界博览会(Expo2010),是第41届世界博览会.于2010年5月1日至10月31日期间, ...

随机推荐

  1. 软件Scrum

    软件海贼团 OnePiece (版权所有) 最近迷上了“海贼王”这部动画片,不仅仅是因为其中的人物个个性格鲜明,剧情跌宕起伏扣人心弦,各种耍宝搞笑,还感觉到这个团队很像理想中的敏捷软件团队. 作为一直 ...

  2. UML六种关系

    UML六种关系 基础之上,并对其进行了扩展.在程序中是通过继承类实现的.比如狗是对动物的具体描述,在面向对象设计的时候一般把狗设计为动物的子类. 表示方法:空心三角形箭头的实线,子类指向父类 实现 概 ...

  3. SQLSERVER到底能识别多少个逻辑CPU?

    SQLSERVER到底能识别多少个逻辑CPU? SQLSERVER到底能识别多少个逻辑CPU? 前言 在前几天在论坛有人遇到SQLSERVER识别逻辑CPU的问题 帖子地址: http://socia ...

  4. DropDownList单选与多选下拉框

    一.单选DropDownList传值 1.添加界面的DropDownList显示值问题 (1)在方法内添加ViewData的方法: var ad = new UnitsRepository(); Vi ...

  5. Lync Server 2013中央管理存储:自动收集配置数据失败

    Lync Server 2013在安装本地配置存储到配置中央管理存储的本地副本时候提示错如信息:自动收集配置数据失败. 打开Lync Shell,输入Get-CsConfigurationStoreL ...

  6. 40w会议投票系统优化方案

    40w会议投票系统优化方案 最近2天谈了一个项目,根据提出的需求是,该系统本来是属于一个大系统的分割出来的一个很小的系统,但是由于是并发关系会耗费资源很大,所以分割出来.据了解,系统采用的mysql+ ...

  7. 笔记本WiFi共享

    1.桌面右击新建txt文件复制下面两行代码,修改文件后缀名为bat保存文件 netsh wlan set hostednetwork mode=allow ssid=zhangxh key=xiaoh ...

  8. Flexible 弹性盒子模型之CSS align-items 属性

    实例 居中对齐弹性盒的各项 <div> 元素: div { display: flex; align-items:center; } 复制 效果预览 浏览器支持 表格中的数字表示支持该属性 ...

  9. Mac下使用charles遇到的问题以及解决办法

    最近使用上了Charles,因为之前一直使用Fidder,所以还是碰到了一些问题,这里记录一下. 如何安装破解版 打开charles后,发现访问但是抓不到包 抓取HTTPS的接口,看response是 ...

  10. The Linux Mint 17.1:Eclipse Run The C++ And Python Configoration

    p { margin-bottom: 0.1in; line-height: 120% } # Copyright (c) 2016, 付刘伟 (Liuwei Fu)# All rights rese ...