2017 icpc 南宁赛区 B.Train Seats Reservation(水题)
2017-09-26 18:51
393 查看
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<
f798
/span> to
station 1010 can
share a seat with another passenger from station 3030to 6060.
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 nn reservations;
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.
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.
2017
ACM-ICPC 亚洲区(南宁赛区)网络赛
【题解】
水题,用个数组开100,置为0,每次输入一个区间就把该区间内的值加上s(输入的值),最后扫一遍找到最大的值就是结果。
【AC代码】
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=105;
int m,n;
int aa
;
int main()
{
int a,b,s;
while(~scanf("%d",&m))
{
if(m == 0){
printf("*\n");
continue;
}
memset(aa,0,sizeof aa);
for(int i=0;i<m;++i)
{
scanf("%d%d%d",&a,&b,&s);
for(int j=a;j<b;++j)
aa[j]+=s;
}
int ans=0;
for(int i=1;i<=100;++i)
ans = max(aa[i],ans);
printf("%d\n",ans);
}
return 0;
}
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<
f798
/span> to
station 1010 can
share a seat with another passenger from station 3030to 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 nn reservations;
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 *
题目来源
2017ACM-ICPC 亚洲区(南宁赛区)网络赛
【题解】
水题,用个数组开100,置为0,每次输入一个区间就把该区间内的值加上s(输入的值),最后扫一遍找到最大的值就是结果。
【AC代码】
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=105;
int m,n;
int aa
;
int main()
{
int a,b,s;
while(~scanf("%d",&m))
{
if(m == 0){
printf("*\n");
continue;
}
memset(aa,0,sizeof aa);
for(int i=0;i<m;++i)
{
scanf("%d%d%d",&a,&b,&s);
for(int j=a;j<b;++j)
aa[j]+=s;
}
int ans=0;
for(int i=1;i<=100;++i)
ans = max(aa[i],ans);
printf("%d\n",ans);
}
return 0;
}
相关文章推荐
- 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 亚洲区(南宁赛区)网络赛-- B. Train Seats Reservation-(区间更新,单点查询思想)
- ACM 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Train Seats Reservation
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation
- B. Train Seats Reservation 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017ICPC南宁赛区网络赛 Train Seats Reservation (简单思维)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Overlapping Rectangles
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 A. Weather Patterns
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 G. Finding the Radius for an Inserted Circle
- 【计算几何】【圆反演】计蒜客17314 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 G. Finding the Radius for an Inserted Circle
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 (B,F,L,M)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:Frequent Subsets Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Overlapping Rectangles
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:L. The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:Overlapping Rectangles