Description

[Brian Dean, 2014] Bessie the cow is competing in a cross-country skiing event at the winter Moolympic games. She starts out at a speed of 1 meter per second. However, as she becomes more tired over time, she begins to slow down. Each time Bessie slows down, her speed decreases: she moves at 1/2 meter per second after slowing down once, then 1/3 meter per second after slowing down twice, and so on. You are told when and where Bessie slows down, in terms of a series of events. An event like this:

T 17

means that Bessie slows down at a specific time -- here, 17 seconds into the race. An event like this:

D 10

means that Bessie slows down at a specific distance from the start -- in this case, 10 meters. Given a list of N such events (1 <= N <= 10,000), please compute the amount of time, in seconds, for Bessie to travel an entire kilometer. Round your answer to the nearest integer second (0.5 rounds up to 1).

奶牛的初始速度为1m/s,第i次减速后速度为1/(i+1) m/s,给出给定N次减速事件,T x表示在x秒减速,D x表示在离起点x米处减速,减速事件不以时间顺序给出,并且可能同时发生,问跑完1000米所用时间 

Input

* Line 1: The value of N.

* Lines 2..1+N: Each line is of the form "T x" or "D x", indicating a time event or a distance event. In both cases, x is an integer that is guaranteed to place the event before Bessie reaches one kilometer of total distance. It is possible for multiple events to occur simultaneously, causing Bessie to slow down quite a bit all at once. Events may not be listed in order.

Output

* Line 1: The total time required for Bessie to travel 1 kilometer.

Sample Input

2
T 30
D 10

INPUT DETAILS: Bessie slows down at time t = 30 and at distance d = 10.

Sample Output

2970

OUTPUT DETAILS: Bessie travels the first 10 meters at 1 meter/second, taking 10 seconds. She then slows down to 1/2 meter/second, taking 20 seconds to travel the next 10 meters. She then reaches the 30 second mark, where she slows down again to 1/3 meter/second. The remaining 980 meters therefore take her 980 * 3 = 2940 seconds. The total time is therefore 10 + 20 + 2940 = 2970.

HINT

在枚举距离的时候同时更新时间

 #include<cstdio>
#include<cmath>
#include<algorithm>
#define inf 598460606
using namespace std;
int n,per=;
int lt,ld,nt=;
char ch[];
double t[],d[],x,nowt;
int main()
{
scanf("%d",&n);
for (int i=;i<=n;i++)
{
scanf("%s%lf",ch,&x);
if (ch[]=='T')t[++lt]=x;
else d[++ld]=x;
}
d[++ld]=;
d[++ld]=;
sort(d+,d+ld+);
sort(t+,t+lt+);
for(int i=;i<ld;i++)
{
double nd=d[i];
while (nd<d[i+]&&nt<=lt&&nowt+(d[i+]-nd)*per>t[nt])
{
nd+=(t[nt]-nowt)/per;
per++;
nowt=t[nt++];
}
nowt+=(d[i+]-nd)*per;
per++;
}
if (nowt-(int)nowt>0.5)nowt=(int)nowt+;
else nowt=(int)nowt;
printf("%.0lf\n",nowt);
}

bzoj3431

bzoj3431 [Usaco2014 Jan]Bessie Slows Down的更多相关文章

  1. BZOJ3433: [Usaco2014 Jan]Recording the Moolympics

    3433: [Usaco2014 Jan]Recording the Moolympics Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 55  So ...

  2. 3433: [Usaco2014 Jan]Recording the Moolympics

    3433: [Usaco2014 Jan]Recording the Moolympics Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 137  S ...

  3. 洛谷P2338 Bessie Slows Down S 题解

    题目 [USACO14JAN]Bessie Slows Down S 题解 这道题其实蛮简单的,不知道为什么难度划到了提高+,个人觉得这难度大概就是普及左右. 具体说说怎么做吧,简单模拟一下即可,始终 ...

  4. BZOJ 3432: [Usaco2014 Jan]Cross Country Skiing (二分+染色法)

    还是搜索~~可以看出随着D值的增大能到达的点越多,就2分d值+染色法遍历就行啦~~~ CODE: #include<cstdio>#include<iostream>#incl ...

  5. 【BZOJ】3433: [Usaco2014 Jan]Recording the Moolympics (贪心)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3433 想了好久啊....... 想不出dp啊......sad 后来看到一英文题解......... ...

  6. 【BZOJ】3432: [Usaco2014 Jan]Cross Country Skiing (bfs+二分)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3432 题目说要相互可达,但是只需要从某个点做bfs然后判断其它点是否可达即可. 原因太简单了.... ...

  7. BZOJ 3433 [Usaco2014 Jan]Recording the Moolympics:贪心

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3433 题意: 给出n个区间[a,b). 有两个记录器,每个记录器中存放的区间不能重叠. 求 ...

  8. BZOJ 3430: [Usaco2014 Jan]Ski Course Rating(并查集+贪心)

    题面 Time Limit: 10 Sec Memory Limit: 128 MB Submit: 136 Solved: 90 [Submit][Status][Discuss] Descript ...

  9. 【bzoj 3433】{Usaco2014 Jan} Recording the Moolympics(算法效率--贪心)

    题意:给出n个区间[a,b),有2个记录器,每个记录器中存放的区间不能重叠.求2个记录器中最多可放多少个区间. 解法:贪心.只有1个记录器的做法详见--关于贪心算法的经典问题(算法效率 or 动态规划 ...

随机推荐

  1. android使用BlueStacks作为模拟器

    android原生的模拟器启动比较慢,偶尔还会出现一些莫名的问题,我们除了可以使用我们的android手机来进行调试外,还可以使用第三方的android模拟器,例如BlueStacks模拟器: 相对原 ...

  2. poj1185:炮兵阵地(状压dp)

    也算是比较基础的状压dp了,跟做过的第二道比较又稍微复杂了一点 需要记录之前两行的状态.. 统计结果也稍有不同 另外还学习了一个得到一个整数二进制位 1 的个数的位运算方法 详见代码: #includ ...

  3. VC青睐服装订制网站 市场规模超3000亿美元 - 找VC - 创业邦

    VC青睐服装订制网站 市场规模超3000亿美元 - 找VC - 创业邦 VC青睐服装订制网站 市场规模超3000亿美元

  4. Spring初学(一)

    Spring核心机制:依赖注入 依赖注入简单的理解就是 由Spring负责对model进行设置,而非由controller直接设置. 通过依赖注入,javaEE各种组件可以解耦. 依赖注入(Depen ...

  5. JAVA联调接口跨域解决办法

    JAVA联调接口跨域解决办法 第一种代码: HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,HttpStatus. ...

  6. 如何在 Android 手机上实现抓包?

    如何在 Android 手机上实现抓包? http://www.zhihu.com/question/20467503 我想知道某个应用究竟在数据提交到哪里,提交了什么.网上的教程太复杂,不想麻烦.有 ...

  7. (转)iOS7界面设计规范(1) - UI基础 - 为iOS7而设计

    今天开个新坑.其实老早就想做这事儿了.记得前一两年,苹果官方还会在开发者中心提供中文的HIG(Human Interface Guideline),后来给没了:网上能够找到的中文版本不知是官方还是同行 ...

  8. DEV PivotGridControl 全选行或列

    foreach (string item in fieldProductName.FilterValues.Values) { pivotGridControl.Cells.SetSelectionB ...

  9. F# 越用越喜欢

    F# 越用越喜欢 最近由于需要,把遗忘了几年的F#又捡了起来.说捡了起来,倒不如说是从头学习,原来学的早已经忘了!所谓学过,只不过看过一本<F# 语言程序设计> (郑宇军 凌海风 编著 - ...

  10. 使用.NET框架、Web service实现Android的文件上传(一)

    上面是上传结果的展示,下面具体讲一下实现过程. 一.Web Service (.NET) namespace VedioPlayerWebService.service.vedios { [WebSe ...