You are given a list of train stations, say from the station 111 to the station 100100100.

The passengers can order several tickets from one station to another before the train leaves the station one. We will issue one train from the station 111 to the station 100100100 after all reservations have been made. Write a program to determine the minimum number of seats required for all passengers so that all reservations are satisfied without any conflict.

Note that one single seat can be used by several passengers as long as there are no conflicts between them. For example, a passenger from station 111 to station 101010 can share a seat with another passenger from station 303030 to 606060.

Input Format

Several sets of ticket reservations. The inputs are a list of integers. Within each set, the first integer (in a single line) represents the number of orders, nnn, which can be as large as 100010001000. After nnn, there will be nnn lines representing the nnn reservations; each line contains three integers s,t,ks, t, ks,t,k, which means that the reservation needs kkk seats from the station sss to the station ttt .These ticket reservations occur repetitively in the input as the pattern described above. An integer n=0n = 0n=0 (zero) signifies the end of input.

Output Format

For each set of ticket reservations appeared in the input, calculate the minimum number of seats required so that all reservations are satisfied without conflicts. Output a single star '*' to signify the end of outputs.

样例输入

2
1 10 8
20 50 20
3
2 30 5
20 80 20
40 90 40
0

样例输出

20
60
* 一开始当贪心做了。。。就很蠢。。。然后看都600+过了怎么肥四。。
然后发现直接开个数字记录和再找最大值就好。。
傻了傻了。。
 #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
long long vis[];
bool cmp(long long a,long long b)
{
return a > b;
} int main()
{
int n;
while(~scanf("%d",&n))
{
if(n==){
printf("*\n");
break;
}
int s,t;
long long k;
memset(vis,,sizeof(vis));
for(int i=;i<n;i++)
{
scanf("%d%d%lld",&s,&t,&k);
for(int j=s;j<t;j++)
vis[j]+=k;
}
sort(vis+,vis+,cmp);
printf("%lld\n",vis[]); }
return ;
}

2017ICPC南宁赛区网络赛 Train Seats Reservation (简单思维)的更多相关文章

  1. 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Train Seats Reservation

    You are given a list of train stations, say from the station 11 to the station 100100. The passenger ...

  2. 2017ICPC南宁赛区网络赛 Minimum Distance in a Star Graph (bfs)

    In this problem, we will define a graph called star graph, and the question is to find the minimum d ...

  3. 2017ICPC南宁赛区网络赛 Overlapping Rectangles(重叠矩阵面积和=离散化模板)

    There are nnn rectangles on the plane. The problem is to find the area of the union of these rectang ...

  4. 2017ICPC南宁赛区网络赛 The Heaviest Non-decreasing Subsequence Problem (最长不下降子序列)

    Let SSS be a sequence of integers s1s_{1}s​1​​, s2s_{2}s​2​​, ........., sns_{n}s​n​​ Each integer i ...

  5. 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M. Frequent Subsets Problem【状态压缩】

    2017 ACM-ICPC 亚洲区(南宁赛区)网络赛  M. Frequent Subsets Problem 题意:给定N和α还有M个U={1,2,3,...N}的子集,求子集X个数,X满足:X是U ...

  6. 2017ICPC北京赛区网络赛 Minimum(数学+线段树)

    描述 You are given a list of integers a0, a1, …, a2^k-1. You need to support two types of queries: 1. ...

  7. 2017ICPC北京赛区网络赛 Visiting Peking University(简单思维)

    描述 Ming is going to travel for n days and the date of these days can be represented by n integers: 0 ...

  8. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

  9. HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛)

    HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛) Panda Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: ...

随机推荐

  1. 5月21 回话控制SESSION COOKIE

    百科 HTTP普及(无状态性) 超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议.所有的WWW文件都必须遵守这个标准.设计HTTP ...

  2. linux平台的oracle11201借用expdp定时备份数据库

    备份脚本如下: #!/bin/bashexport ORACLE_BASE=/data/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db ...

  3. oracle数据库中字符乱码

    1.1         88.152 os已安装中文包,以下确认os层面中文是否可以显示 1.2         88.153 os没有安装中文包,以下确认os层面中文无法显示 1.3         ...

  4. [POJ题目分类][转]

    Hint:补补基础... 初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治 ...

  5. Boost.PropertyTree读取ini文件(Linux环境)

    昨天因为需要读取配置文件略略伤神.网上很多例子但是我用都会报错,很多人把Boost.PropertyTree的函数写很麻烦的包所以报错我也不知道什么问题,所以今天整理下. 头上附上官网链接:Boost ...

  6. 【转】vue技术分享-你可能不知道的7个秘密

    一.善用watch的immediate属性 这一点我在项目中也是这么写的.例如有请求需要再也没初始化的时候就执行一次,然后监听他的变化,很多人这么写: created(){ this.fetchPos ...

  7. 文件查找命令find

    十六. 文件查找命令find: 下面给出find命令的主要应用示例:    /> ls -l     #列出当前目录下所包含的测试文件    -rw-r--r--. 1 root root 48 ...

  8. 使用JdbcTemplate操作数据库(二十九)

    使用JdbcTemplate操作数据库 Spring的JdbcTemplate是自动配置的,你可以直接使用@Autowired来注入到你自己的bean中来使用. 举例:我们在创建User表,包含属性n ...

  9. [Java] 各种流的分类及区别

    https://www.cnblogs.com/lca1826/p/6427177.html 流在Java中是指计算中流动的缓冲区. 从外部设备流向中央处理器的数据流成为“输入流”,反之成为“输出流” ...

  10. redis事件监听及在订单系统中的使用

    https://blog.csdn.net/qq_37334135/article/details/77717248 通常在网上买好物品,或者说手机扫码后,点击付款,这时就会向后台发送请求,生成订单信 ...