2017-09-24 19:16:38

writer:pprp

题目链接:https://www.jisuanke.com/contest/877

题目如下:

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 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
* 分析:这是一个求解重叠区间最大和的问题,签到题...ai
将起点设为正数,终点设为负数,扫描一遍就可以知道区间中最大值 代码如下:
//ac B
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std; const int maxn = ;
int a[maxn]; int main()
{
freopen("in.txt","r",stdin);
int n;
while(cin>>n)
{
if(n==)
{
cout<<"*"<<endl;
break;
} memset(a,,sizeof(a)); while(n--)
{
int s,t,k;
cin>>s>>t>>k;
a[s]+=k;
a[t]-=k;
}
int ans=,temp=;
for(int i=; i<=; i++)
{
temp+=a[i];
ans=max(ans,temp);
} cout<<ans<<endl;
}
return ;
}

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B题的更多相关文章

  1. 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 ...

  2. HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛)

    HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛) Panda Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: ...

  3. Skiing 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛H题(拓扑序求有向图最长路)

    参考博客(感谢博主):http://blog.csdn.net/yo_bc/article/details/77917288 题意: 给定一个有向无环图,求该图的最长路. 思路: 由于是有向无环图,所 ...

  4. 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)

    摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...

  5. ICPC 2018 徐州赛区网络赛

    ACM-ICPC 2018 徐州赛区网络赛  去年博客记录过这场比赛经历:该死的水题  一年过去了,不被水题卡了,但难题也没多做几道.水平微微有点长进.     D. Easy Math 题意:   ...

  6. [刷题]ACM/ICPC 2016北京赛站网络赛 第1题 第3题

    第一次玩ACM...有点小紧张小兴奋.这题目好难啊,只是网赛就这么难...只把最简单的两题做出来了. 题目1: 代码: //#define _ACM_ #include<iostream> ...

  7. 2016 ACM/ICPC亚洲区大连站-重现赛 解题报告

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5979 按AC顺序: I - Convex Time limit    1000 ms Memory li ...

  8. 2014ACM/ICPC亚洲区鞍山赛区现场赛1009Osu!

    鞍山的签到题,求两点之间的距离除以时间的最大值.直接暴力过的. A - Osu! Time Limit:1000MS     Memory Limit:262144KB     64bit IO Fo ...

  9. 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 ...

  10. 2017ICPC南宁赛区网络赛 Overlapping Rectangles(重叠矩阵面积和=离散化模板)

    There are nnn rectangles on the plane. The problem is to find the area of the union of these rectang ...

随机推荐

  1. 为什么在Java中不使用finalize()方法

    我们都知道finalize()方法是回收分配给对象的内存之前调用垃圾收集器线程的基本语句.在这篇文章中,我们将会深入这个方法. 这篇文章中的章节: 1.finalize()方法不能保证执行(这个将要用 ...

  2. 网络爬虫之scrapy框架设置代理

    前戏 os.environ()简介 os.environ()可以获取到当前进程的环境变量,注意,是当前进程. 如果我们在一个程序中设置了环境变量,另一个程序是无法获取设置的那个变量的. 环境变量是以一 ...

  3. php 计算gps坐标 距离

    在计算机或GPS上经纬度经常用度.分.秒和度.度.分.分.秒.秒的混合方式进行表示,度.分.秒间的进 制是60进制,度.度.分.分. 秒.秒的进制是100进制,换算时一定要注意.可以近似地认为每个纬度 ...

  4. POJ2480:Longge's problem(欧拉函数的应用)

    题目链接:传送门 题目需求: Given an integer N(1 < N < 2^31),you are to calculate ∑gcd(i, N) 1<=i <=N ...

  5. 项目实战:Mahout构建图书推荐系统

    前言 本文是Mahout实现推荐系统的又一案例,用Mahout构建图书推荐系统.与之前的两篇文章,思路上面类似,侧重点在于图书的属性如何利用.本文的数据在自于Amazon网站,由爬虫抓取获得. 目录 ...

  6. 在MFC中实现对象之间数据的传递。

    方法一: 第一步:在VS2010里面新建一个单文档MFC程序. 第二步:在App类里面的头文件里面 定义性声明一个变量 ,见下面程序 public: CString ii; 第三步:在App类的实现文 ...

  7. 基于java的网络爬虫框架(实现京东数据的爬取,并将插入数据库)

    原文地址http://blog.csdn.net/qy20115549/article/details/52203722 本文为原创博客,仅供技术学习使用.未经允许,禁止将其复制下来上传到百度文库等平 ...

  8. 浅析selenium的PageFactory模式 PageFactory初始化pageobject

    1.首先介绍FindBy类: For example, these two annotations point to the same element: @FindBy(id = "foob ...

  9. 131. Palindrome Partitioning(回文子串划分 深度优先)

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

  10. windows平台kettle连接hbase的问题

    我本机安装的环境是centos7,并在本机上安装了zookeeper,hadoop,hbase,hive等组件, 使用pdi7.1来连接hbase,把mysql表中的数据导出到hbase中去,没有问题 ...