挖掘机(dig.*)

背景

附中机房谁最虚?高二一班***!感觉很顺,是吧?

题目描述

今天,丧尸czy开着挖掘机去上学(……)。但是他发现他的mz满天下,所以一路上他碰到了好多他的mz。一开始他以1km/min的速度(=60km/h……)开着挖掘机前进。他发现他只会在恰好到达某一时刻或者到达某个距离遇到mz。每次遇到mz,czy都会毫不犹豫的把她们顺路捎走(^_^)。但是他实在是太虚了,以至于当有i个mz时他的速度下降到1/(i+1)。具体说,一开始czy以1km/min速度前进,有1个mz的时候速度变为1/2 km/min,有2个时变为1/3 km/min……以此类推。现在问题来了,给出每个mz在何时出现,请你算出czy到学校要多久。

格式

输入第一行2个数n,m,分别表示mz数和czy与学校的距离(km)

接下来2到n+1行由字符串与数字构成

Dist  x表示在距离达到x km时出现一个mz

Time  x表示在时间达到x min时出现一个mz

输出一个整数,表示到达学校的时间。如果不能整除,直接输出整数部分即可。

样例输入

2 20

Time 3

Dist 10

样例输出

47

数据范围

对于30%数据,n,m<=50

对于50%数据,n,m<=2000

对于100%数据,n,m<=200000,x<=10^9,保证输入的数字都是整数

type arr=array[..] of longint;

var t,d:arr;
n,m,i,j,x,c,d1,t1,d2,t2,sum:longint;
v,time,tt,pred,s:real;
ans:int64;
ss:string; procedure sort(l,r: longint;var a:arr);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div ];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-;
end;
until i>j;
if l<j then
sort(l,j,a);
if i<r then
sort(i,r,a);
end; procedure printf;
begin
ans:=trunc(time);
writeln(ans);
halt;
end; procedure init;
var i:longint;
begin
readln(n,m);
for i:= to n do
begin
readln(ss);
x:=pos('Dist',ss);
if x<> then
begin
inc(d1);
delete(ss,,);
val(ss,d[d1],c);
continue;
end
else
begin
inc(t1);
delete(ss,,);
val(ss,t[t1],c);
continue;
end;
end;
end; procedure change;
begin
// sort(,t1,t);sort(,d1,d);
d2:=;t2:=;
pred:=;time:=;
sum:=;
v:=;
//d1:距离出现妹子总数;d2:当前出现的距离妹子的处理
//d1:时间出现妹子总数;d2:当前出现的时间妹子的处理
//sum:当前是第几个妹子
//v:当前速度
//pred:当前走过的路程;time:当前所用时间
end; procedure main;
begin
while (d2<=d1)and(t2<=t1) do
begin
tt:=(d[d2]-pred)/ v;
if tt+time<=t[t2] then//先碰到距离妹子
begin
time:=time+tt;
inc(sum);
v:=/(sum+);
pred:=d[d2];
inc(d2);
continue;
end
else
begin
s:=v*(t[t2]-time);
pred:=pred+s;
time:=t[t2];
inc(sum);
v:=/(sum+);
inc(t2);
continue;
end;
end;
if pred=m then printf;
for i:=d2 to d1 do
begin
tt:=(d[d2]-pred)/ v;
time:=time+tt;
pred:=d[d2];
inc(sum);
v:=/(sum+);
end;
if pred=m then printf;
for i:=t2 to t1 do
begin
s:=v*(t[t2]-time);
pred:=pred+s;
time:=t[t2];
inc(sum);
v:=/(sum+);
end;
if pred=m then printf;
tt:=(m-pred)/ v;
time:=time+tt;
printf;
end; begin
assign(input,'dig.in');
assign(output,'dig.out');
reset(input);
rewrite(output);
init;
change;
main;
close(input);
close(output);
end.
type arr=array[..] of real;

var t,d:arr;
ans:int64;
n,m,per,i,j,lt,ld,nt:longint;
x,nowt:real; procedure sort(l,r: longint;var a:arr);
var
i,j:longint;x,y:real;
begin
i:=l;
j:=r;
x:=a[(l+r) div ];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-;
end;
until i>j;
if l<j then
sort(l,j,a);
if i<r then
sort(i,r,a);
end; procedure printf;
begin
ans:=trunc(nowt);
writeln(ans);
halt;
end; procedure change;
begin
n:=;
m:=;
per:=;
lt:=;
ld:=;
nt:=;
end; procedure init;
var i,j:longint;ch:char;
begin
readln(n,m);
for i:= to n do
begin
read(ch);
if ch='T' then
begin
for j:= to do read(ch);
inc(lt);
readln(t[lt]);
end
else
begin
for j:= to do read(ch);
inc(ld);
readln(d[ld]);
end;
end;
end; procedure main;
var nd:real;
begin
inc(ld);
d[ld]:=0.0;
inc(ld);
d[ld]:=m;
for i:= to ld- do
begin
nd:=d[i];
while (nd<d[i+])and(nt<=lt)and(nowt+(d[i+]-nd)*per>t[nt]) do
begin
nd:=nd+(t[nt]-nowt)/per;
inc(per);
nt:=nt+;
nowt:=t[nt];
end;
nowt:=nowt+(d[i+]-nd)*per;
inc(per);
end;
end; begin
assign(input,'dig.in');
assign(output,'dig.out');
reset(input);
rewrite(output);
nowt:=;
change;
init;
sort(,ld,d);
sort(,lt,t);
main;
printf;
close(input);
close(output);
end.

AC程序

program dig;
procedure open;
begin
assign(input,'dig.in');
assign(output,'dig.out') ;
reset(input);
rewrite(output);
end; procedure closs;
begin
close(input);
close(output);
end; type zz=array[..] of longint;
var
ch:char;
c,i,n,m,t1,d1,mz,q1,q2:Longint;
t,x:real;
ti,di:zz;
procedure sort(l,r: longint; var a:zz);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div ];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-;
end;
until i>j;
if l<j then
sort(l,j,a);
if i<r then
sort(i,r,a);
end; begin
open;
readln(n,m);
for i:= to n do
begin
read(ch);
case ch of
'T':
begin
read(ch); read(ch); read(ch);
inc(t1);
readln(c);
ti[t1]:=c;
end;
'D':
begin
read(ch); read(ch); read(ch);
inc(d1);
readln(c);
di[d1]:=c;
end;
end;
end;
sort(,t1,ti);
sort(,d1,di);
q1:=; q2:=;
mz:=;
x:=; t:=;
while (q1<=t1) or (q2<=d1) do
begin
if q1<=t1 then
if ((ti[q1]-t)*(/mz)+x<di[q2]) or (q2=d1+) then
begin
x:=x+(ti[q1]-t)/mz;
inc(mz);
t:=ti[q1];
inc(q1);
//writeln(x::,' ',t::);
end;
if q2<=d1 then
if ((ti[q1]-t)*(/mz)+x>di[q2]) or (q1=t1+) then
begin
t:=t+(di[q2]-x)*mz;
inc(mz);
x:=di[q2];
inc(q2);
//writeln(x::,' ',t::);
end;
if (q2<=d1) and (q1<=t1) then
if ((ti[q1]-t)*(/mz)+x=di[q2]) then
begin
t:=ti[q1];
x:=di[q2];
inc(mz,);
inc(q1);
inc(q2);
end;
end;
t:=t+(m-x)*(n+);
writeln(trunc(t));
closs;
end.

[未解出,hzwer]挖掘机的更多相关文章

  1. IOS之未解问题--关于IOS图像渲染CPU和GPU

    前言:先上一个图.关于UIKit底层渲染机制,这个有待以后花大把时间收集资料和学习,然后汇总,将整篇"未解问题"去除. 反思:半个月前阿里电话面试,问道一个问题图像渲染什么时候回用 ...

  2. 【BioCode】删除未算出PSSM与SS的蛋白质序列

    代码说明: 由于一些原因(氨基酸序列过长),没有算出PSSM与SS,按照整理出来的未算出特征的文件,删除原来的蛋白质序列: 需删除的氨基酸文件732.txt(共732条氨基酸): 删除前 氨基酸共25 ...

  3. IOS之未解问题--给UITableView提取UITableViewDataSource并封装瘦身失败

    前言:阅读了<更轻量的 View Controllers>,发现笔者这个优化重构代码的想法真的很不错,可以使得抽取的UITableViewDataSource独立写在一个类文件里,并且也写 ...

  4. 谷歌浏览器chrome与firefox的冲突(未解之谜)

    那年,公司开发了一套在线制作电子书的系统 e-textbook. 我负责小学电脑科教材在线题目的制作. 利用 ps制作剪裁好图片,导入系统,制作题目,并通知同事添加代码. 检测时,却发现有一道图片拖放 ...

  5. 62. Unique Paths(中等,我自己解出的第一道 DP 题^^)

    A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The ...

  6. SimpleDateFormat未抛出ParseException

    关于SimpleDateFormat的不严格性[技术探讨]今天一组员写了几段Java代码,发现如下问题:        SimpleDateFormat sdf = new SimpleDateFor ...

  7. 大话css之display的Block未解之谜(一)

    用了几年的css了,css中inline | block |inline-block|table|flex从来没有做过系统的整理和分析,网上的分析文章也很多,零散. 今天有空,就在这做一下整理分析 b ...

  8. 我要崩溃了,要解出这么一段js代码背后的东西,这真是一坨啊,别被高度欺骗了,他还有宽度!!!!!试着按下方向右键

    一坨js代码: function s_gi(un, pg, ss) { var c = "s.version='H.26';s.an=s_an;s.logDebug=function(m){ ...

  9. iOS之通过PaintCode快速实现交互动画的最方便方法 未解问题

    需求: 问题: 源码百度云下载链接: http://pan.baidu.com/s/1o7r4hCm 密码: 8atd 其他学习链接:http://www.jianshu.com/p/90d6cd35 ...

随机推荐

  1. PHP初学留神(三)

    星期一进行面试结束后,意味着我的考研日子也结束了,以及我的2013.在好好总结之后还不能停止学习,心想着要把算法继续学下去,还有Linux.不过呢,始终都要记住尼采老师的这句当头棒喝:“不加选择的知识 ...

  2. hdu 2079 选课时间

    hdu 2079 选课时间 题意:选的学分总和为n,并且学分为a的课有b种,总共有K(1<=k<=8)种学分不同的课,并且要选的学分最多为40:问选课方案有多少种?(学分相同的课即认为相同 ...

  3. Java学习--封装、继承、多态

    接下来几天会根据http://www.cnblogs.com/chenssy/category/525010.html中讲解的java内容做个学习笔记,在此感谢一下这位大仙!! 一.封装 对于封装而言 ...

  4. 制作UI纹理(UI Texture)

    什么情况下使用UI Texture UI Texture的功能是在屏幕上显示一张图片,在这一点上它和Sprite有着相似的功能,但是UI Texture会消耗单独的DrawCall去渲染,并会单独加载 ...

  5. CLLocationManager 位置定位

    第一步,新建一个singleView的空白工程,如果新建,这里不做赘述了. 第二步:因为地图开发相关的framework:MapKit.framework.CoreLocation.framework ...

  6. WebService积累

    1.缺点,无法传输复杂对象:如无法序列化key/value结构的类型参数以及相关一维集合接口(Hashtable等打上标签[Serializable]即可序列化,不过继承的IDictionary并不可 ...

  7. 简单方法打包.net程序集脱离framework

    最近业余捣鼓monogame,自然而然就关注到了.net程序脱离framework发布的问题上了, 度娘,谷歌娘 都经过一番查找,无非分为如下几类方法: 1.直接使用mono运行时,附带 bin.li ...

  8. 如何确定照片是否被PS过

    除了用软件,还可以先右键属性----解除锁定----重新打开属性看详细信息.

  9. hdu 4814 Golden Radio Base

    详解见:http://blog.csdn.net/tri_integral/article/details/18666797 #include<cstdio> #include<cs ...

  10. 如何避免远程循环执行SSH时,到第一条之后就退出

    RT 今天遇到的小问题,记录下来. 据说关键是加  < /dev/null 我也是看网上别人说的,测试成功. #!/bin/bash while read line do echo $line ...