题目链接: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. linux 安装svn,并设置钩子来同步更新

    linux安装svn下载 http://subversion.tigris.org/downloads/subversion-1.6.6.tar.gz 和 http://subversion.tigr ...

  2. IOS学习之路五(SpriteKit 开发飞机大战小游戏一)

    参考SpriteKit 创建游戏的教程今天自己动手做了一下,现在记录一下自己怎么做的,今天之做了第一步,一共有三个部分. 第一步,项目搭建. 项目所用图片资源:点击打开链接 1.在Xcode打开之后, ...

  3. 业务类接口在TCP,HTTP,BLL模式下的实例 设计模式混搭 附源码一份

    业务类接口在TCP,HTTP,BLL模式下的实例 设计模式混搭 附源码一份 WinForm酒店管理软件--框架这篇随笔可以说是我写的最被大家争议的随笔,一度是支持和反对是一样的多.大家对我做的这个行业 ...

  4. Unity3d物体模型(实现旋转缩放平移自动旋转)

    基本功能实现:物体通过鼠标左键上下移动,中间键缩放.右键旋转,30秒没操作,物体自动旋转 实例代码: using UnityEngine; using System.Collections; publ ...

  5. .net调用Outlook 批量发送邮件,可指定Outlook中的账号来发送邮件

    .net调用Outlook 批量发送邮件,可指定Outlook中的账号来发送邮件 源码可以在我的资源列表中下载: MPOEMail http://download.csdn.net/my VS2012 ...

  6. js 上传下载(留着备用)

      js 上传下载(留着备用) 下载文件 1. <a href="#" onClick="download()">下载文件</a>  & ...

  7. thrift之默认传输类TTransportDefaults和虚拟传输类TVirtualTransport

    默认传输类TTransportDefaults提供了抽象类TTransport的默认实现,实现了非虚拟的方法(*_virt) read(), readAll(), write(),borrow() a ...

  8. Opengl坐标转换

    有时候我们需要手动计算三维点对应的二维坐标,下面的矩阵公式就是模拟了一遍三维图形的流程.这里已假设读者具备了图形学的基础知识,比如矩阵乘法代表的三维变换,放射变换:还有齐次坐标等. 这里不考虑模型自身 ...

  9. Google photos -- reverse thinking

    As a hacker, do the hacking. Here I mean the [hacker](http://en.wikipedia.org/wiki/Hacker_(term) ) . ...

  10. input type="file"去掉取消默认原来选择的文件

    很多时候我们上传文件点击取消后或我们制定了内容格式上传不符合,再次点击input="file"按钮时,选择的文件还是原来的文件,却又上传不.当时想在旁边多添加个按钮清除file里面 ...