2017ICPC南宁赛区网络赛 Train Seats Reservation (简单思维)
2017-09-25 20:40
337 查看
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.
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[1005]; bool cmp(long long a,long long b) { return a > b; } int main() { int n; while(~scanf("%d",&n)) { if(n==0){ printf("*\n"); break; } int s,t; long long k; memset(vis,0,sizeof(vis)); for(int i=0;i<n;i++) { scanf("%d%d%lld",&s,&t,&k); for(int j=s;j<t;j++) vis[j]+=k; } sort(vis+1,vis+101,cmp); printf("%lld\n",vis[1]); } return 0; }
相关文章推荐
- 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
- ACM 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Train Seats Reservation
- Train Seats Reservation 区间加减 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- Train Seats Reservation 2017ACM南宁网络赛
- 2017ICPC北京赛区网络赛 Visiting Peking University(简单思维)
- 2017 icpc 南宁赛区 B.Train Seats Reservation(水题)
- 2017ICPC南宁赛区网络赛 The Heaviest Non-decreasing Subsequence Problem (最长不下降子序列)
- 2017ICPC南宁赛区网络赛 Overlapping Rectangles(重叠矩阵面积和=离散化模板)
- 2017ICPC南宁赛区网络赛 Minimum Distance in a Star Graph (bfs)
- M. Frequent Subsets Problem - 状态压缩-2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 待补
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 G. Finding the Radius for an Inserted Circle
- 【计算几何】【圆反演】计蒜客17314 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 G. Finding the Radius for an Inserted Circle
- 2017年南宁网络赛 L 题 【最长非递减序列 + 思维】