2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation
来源:互联网 发布:python中pyparsing 编辑:程序博客网 时间:2024/05/22 07:59
You are given a list of train stations, say from the station 1 to the station 100.
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 1 to the station 100 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 1 to station 10 can share a seat with another passenger from station 30to 60.
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, n, which can be as large as 1000. After n, there will be n lines representing the n reservations; each line contains three integers s,t,k, which means that the reservation needs k seats from the station s to the station t .These ticket reservations occur repetitively in the input as the pattern described above. An integer n=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.
样例输入
21 10 820 50 2032 30 520 80 2040 90 400
样例输出
2060*
题目来源
2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
题意:每到一个车站有人下车和上车……求需要的最少座位数
解题思路:由于车站很少……直接模拟上下车的过程即可……
#include<iostream>#include<algorithm>#include<math.h>using namespace std;typedef long long int ll;struct point{int shang;int xia;ll k;}list[1005];bool cmp(point a,point b){if(a.shang==b.shang)return a.xia<b.xia;elsereturn a.shang<b.shang;}int main(){int n;while(~scanf("%d",&n)){if(n==0){printf("*\n");break;}ll ans=0;ll mmm=0;for(int i=0;i<n;i++){scanf("%d%d%lld",&list[i].shang,&list[i].xia,&list[i].k);}sort(list,list+n,cmp);for(int i=0;i<100;i++){for(int j=0;j<n;j++){if(list[j].xia==i){ans-=list[j].k;}if(list[j].shang==i){ans+=list[j].k;mmm=max(mmm,ans);}}}printf("%lld\n",mmm);}return 0;}
- ACM 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B.Train Seats Reservation(模拟)
- B. Train Seats Reservation 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B Train Seats Reservation
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Train Seats Reservation
- Train Seats Reservation 区间加减 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:Train Seats Reservation
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation(贪心问题+区间覆盖)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛-- B. Train Seats Reservation-(区间更新,单点查询思想)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation 和 F. Overlapping Rectangles
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛Train Seats Reservation(树状数组的运用)
- 2017 icpc 南宁赛区 B.Train Seats Reservation(水题)
- Train Seats Reservation 2017ACM南宁网络赛
- 2017南宁网络赛B.Train Seats Reservation(初级扫描)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 网络编程
- EasyNVR流媒体服务器接入EasyDSS云视频平台快照上传实现
- JavaScript中的‘&&’、‘||’操作符
- SQL commands Glossary of commonly used SQL commands
- 游戏开发判断网络是否连接
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation
- 【牛客网】魔法币
- 将Excel中的数据转换成sql Insert语句
- Python:重命名文件,尤其要注意路径!写全!
- 背包问题--贪心算法C#Demo解析
- Spark2.x学习笔记:10、简易电影受众系统
- 在百度上找的,eclipse上安装tomcat
- labelImg windows10 安装
- hive内置函数