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. java把list分成几个list

    public static void main(String[] args) { List<String> list=new ArrayList<>(); list.add(& ...

  2. python-day72--django实现的cookie/session

    COOKIE 与 SESSION 一.概念cookie不属于http协议范围,由于http协议无法保持状态,但实际情况,我们却又需要“保持状态”,因此cookie就是在这样一个场景下诞生.cookie ...

  3. H5活动页面与APP交互规则

    IOS: 用户信息请求:window.webkit.messageHandlers.GetUserInfo.postMessage(jsonData); 参数:jsonData 回调方法:iosDel ...

  4. bootstrap居中

    1.页面 <div class="container"> <div class="row clearfix"> <div clas ...

  5. GetMapping 和 PostMapping最大的差别(转)

    原文地址:GetMapping 和 PostMapping  Spring4.3中引进了{@GetMapping.@PostMapping.@PutMapping.@DeleteMapping.@Pa ...

  6. weblogic补丁安装失败(Patch B25A is mutually exclusive and cannot coexist with patch(es): UIAL)

    由于曝出漏洞(CVE-2017-3248)需要将weblogic补丁更新至B25A,但是出现报错.如下: Conflict(s) detected - resolve conflict conditi ...

  7. pycharm 配置使用

    1. 如何添加Package File-> Settings -> Project :XXXX -> Project Interpreter 点右边的"+"号,输 ...

  8. vue 小知识

    图片: 1.img 的路径 <img :src="item.src"/> 2.背景图片的路径 v-bind:style="{backgroundImage: ...

  9. localStorage 设置本地缓存

    var timestamp = parseInt(Date.parse(new Date()));var btn = document.getElementById("close" ...

  10. Oracle.PL/SQL高级

    一.匿名块 .使用returning ... INTO 保存增删改表数据时的一些列的值 ()增加数据时保存数据 DECLARE v_ename emp.ename%TYPE; v_sal emp.sa ...