挖掘机(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. Cassandra1.2文档学习(4)——分区器

    参考文档:http://www.datastax.com/documentation/cassandra/1.2/webhelp/index.html#cassandra/architecture/a ...

  2. struct timespec 和 struct timeval

    time()提供了秒级的精确度 . 1.头文件 <time.h> 2.函数原型 time_t time(time_t * timer) 函数返回从TC1970-1-1 0:0:0开始到现在 ...

  3. ecshop会员中心增加订单搜索功能

    在user.php中的act=order_list中增加以下程序. $order_sn = isset($_REQUEST['order_sn'])?$_REQUEST['order_sn']:''; ...

  4. 3.bit-map

    适用范围:可进行数据的快速查找,判重,删除,一般来说数据范围是int的10倍以下 基本原理及要点:使用bit数组来表示某些元素是否存在,比如8位电话号码 扩展:bloom filter可以看做是对bi ...

  5. CSS3学习之 animation 属性

    发现animation这个新属性很有趣,在此学习,并整理下!  浏览器支持: Internet Explorer 10.Firefox 以及 Opera 支持 animation 属性: Safari ...

  6. java 发布和逸出

    [转载]:http://www.2cto.com/kf/201310/247738.html 前言 多线程并发环境下,线程安全极为重要.往往一些问题的发生都是由于不正确的发布了对象造成了对象逸出而引起 ...

  7. Burp Suite Walkthrough(英文版)

    Burp Suite is one of the best tools available for web application testing. Its wide variety of featu ...

  8. POJ 3321 Apple Tree(树状数组)

    点我看题目  题意 : 大概是说一颗树有n个分岔,然后给你n-1对关系,标明分岔u和分岔v是有边连着的,然后给你两个指令,让你在Q出现的时候按照要求输出. 思路 :典型的树状数组.但是因为没有弄好数组 ...

  9. UVA 10651 Pebble Solitaire 状态压缩dp

    一开始还在纠结怎么表示一个状态,毕竟是一个串.后来搜了一下题解发现了这里用一个整数的前12位表示转态就好了 ,1~o,0~'-',每个状态用一个数来表示,然后dp写起来就比较方便了. 代码: #inc ...

  10. *[codility]ArrayInversionCount

    http://codility.com/demo/take-sample-test/arrayinversioncount 求逆序对数,归并排序并记录逆序次数. // you can also use ...