2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Train Seats Reservation
You are given a list of train stations, say from the station 11 to
the station 100100.
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 11 to
the station 100100 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 11 to
station 1010 can
share a seat with another passenger from station 3030 to 6060.
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, nn,
which can be as large as 10001000.
After nn,
there will be nn lines
representing the nnreservations;
each line contains three integers s,
t, ks,t,k,
which means that the reservation needs kk seats
from the station ss to
the station tt.These
ticket reservations occur repetitively in the input as the pattern described above. An integer n
= 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
*
题目来源
很水的一个题,队友想得及其复杂,就是把1-100分成100段,分别是1-2,2-3,3-4……99-100
对输入的范围进行累加,输出值最大的那个单位段
#include <iostream>
//#include<math.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=110;
int train[maxn];
int main()
{
int n;
while(cin>>n)
{
if(n==0)
{
cout<<"*"<<endl;
break;
}
memset(train,0,sizeof(train));
int l,r,num;
int maxsum=0;
for(int j=0;j<n;j++)
{
cin>>l>>r>>num;
for(int i=l;i<r;i++)
{
train[i]+=num;
}
for(int i=0;i<=100;i++)
{
maxsum=max(maxsum,train[i]);
}
}
cout<<maxsum<<endl;
}
return 0;
}
2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Train Seats Reservation的更多相关文章
- 2017ICPC南宁赛区网络赛 Train Seats Reservation (简单思维)
You are given a list of train stations, say from the station 111 to the station 100100100. The passe ...
- 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 ...
- HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛)
HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛) Panda Time Limit: 10000/4000 MS (Java/Others) Memory Limit: ...
- 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)
摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...
- ICPC 2018 徐州赛区网络赛
ACM-ICPC 2018 徐州赛区网络赛 去年博客记录过这场比赛经历:该死的水题 一年过去了,不被水题卡了,但难题也没多做几道.水平微微有点长进. D. Easy Math 题意: ...
- Skiing 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛H题(拓扑序求有向图最长路)
参考博客(感谢博主):http://blog.csdn.net/yo_bc/article/details/77917288 题意: 给定一个有向无环图,求该图的最长路. 思路: 由于是有向无环图,所 ...
- [刷题]ACM/ICPC 2016北京赛站网络赛 第1题 第3题
第一次玩ACM...有点小紧张小兴奋.这题目好难啊,只是网赛就这么难...只把最简单的两题做出来了. 题目1: 代码: //#define _ACM_ #include<iostream> ...
- 2016 ACM/ICPC亚洲区大连站-重现赛 解题报告
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5979 按AC顺序: I - Convex Time limit 1000 ms Memory li ...
- 2014ACM/ICPC亚洲区鞍山赛区现场赛1009Osu!
鞍山的签到题,求两点之间的距离除以时间的最大值.直接暴力过的. A - Osu! Time Limit:1000MS Memory Limit:262144KB 64bit IO Fo ...
随机推荐
- Uva - 12230 Crossing Rivers (数学期望)
你住在村庄A,每天需要过很多条河到另一个村庄B上班,B在A的右边,所有的河都在A,B之间,幸运的是每条船上都有自由移动的自动船, 因此只要到达河左岸然后等船过来,在右岸下船,上船之后船的速度不变.现在 ...
- BootStrap3栅格系统与布局
栅格系统与布局 Use our powerful mobile-first flexbox grid to build layouts of all shapes and sizes thanks t ...
- [52ABP系列] - 002、模板项目配合代码生成器开发
前言 本篇的主要内容是 52ABP SPA模板如何配合52ABP代码生成器开发项目 如果不了解 52ABP 项目请先看我的第一篇文章 [52ABP系列] - 001.SPA免费项目模版搭建教程 话不多 ...
- Unix时间戳(Unix timestamp)转换
http://tool.chinaz.com/Tools/unixtime.aspx 如何在不同编程语言中获取现在的Unix时间戳(Unix timestamp)? Java time JavaScr ...
- php设计模式——模板模式
最近打算巩固,整理一下设计模式相关的内容.这篇是关于 ——模板模式! 原文:http://www.jb51.net/article/76052.htm ----------------------- ...
- [Java Sprint] Spring Configuration Using Java
There is no applicationContext.xml file. Too much XML Namespaces helped Enter Java Configuration Cre ...
- 自己动手写Android数据库框架
前言 相信不少开发人员跟我一样,每次都非常烦恼自己写数据库,并且那些数据库语句也经常记不住.当然网上也有非常多非常好的数据库框架,你能够直接拿来用,可是 非常多时候我们的项目.特别是一个小型的Andr ...
- mysql改动默认的环境的字符集为utf-8
mysql改动环境的默认字符集为utf-8(当然你也能够设置成别的,国际点还是utf-8好) 假设不把mysql字符集统一下.后面还是有点麻烦的 首先得在服务里关掉mysql的服务(一定要先关掉mys ...
- Enterprise Library 5.0 学习笔记
近期了解了微软提供的企业开发框架Enterprise Library,眼下最新版本号是6.0,可是不支持FW3.5.所以就学习了5.0的版本号,EL5.0支持FW3.5和4.0,官网下载地址是:htt ...
- DBCP,C3P0,Tomcat_JDBC 性能及稳定性測试
原创文章,转载请指明出处:http://aub.iteye.com/blog/1404219, 尊重他人即尊重自己 DBCP,C3P0,Tomcat_JDBC 性能及稳定性測试 1.測试环境: 硬件环 ...