[未解出,hzwer]挖掘机
挖掘机(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]挖掘机的更多相关文章
- IOS之未解问题--关于IOS图像渲染CPU和GPU
前言:先上一个图.关于UIKit底层渲染机制,这个有待以后花大把时间收集资料和学习,然后汇总,将整篇"未解问题"去除. 反思:半个月前阿里电话面试,问道一个问题图像渲染什么时候回用 ...
- 【BioCode】删除未算出PSSM与SS的蛋白质序列
代码说明: 由于一些原因(氨基酸序列过长),没有算出PSSM与SS,按照整理出来的未算出特征的文件,删除原来的蛋白质序列: 需删除的氨基酸文件732.txt(共732条氨基酸): 删除前 氨基酸共25 ...
- IOS之未解问题--给UITableView提取UITableViewDataSource并封装瘦身失败
前言:阅读了<更轻量的 View Controllers>,发现笔者这个优化重构代码的想法真的很不错,可以使得抽取的UITableViewDataSource独立写在一个类文件里,并且也写 ...
- 谷歌浏览器chrome与firefox的冲突(未解之谜)
那年,公司开发了一套在线制作电子书的系统 e-textbook. 我负责小学电脑科教材在线题目的制作. 利用 ps制作剪裁好图片,导入系统,制作题目,并通知同事添加代码. 检测时,却发现有一道图片拖放 ...
- 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 ...
- SimpleDateFormat未抛出ParseException
关于SimpleDateFormat的不严格性[技术探讨]今天一组员写了几段Java代码,发现如下问题: SimpleDateFormat sdf = new SimpleDateFor ...
- 大话css之display的Block未解之谜(一)
用了几年的css了,css中inline | block |inline-block|table|flex从来没有做过系统的整理和分析,网上的分析文章也很多,零散. 今天有空,就在这做一下整理分析 b ...
- 我要崩溃了,要解出这么一段js代码背后的东西,这真是一坨啊,别被高度欺骗了,他还有宽度!!!!!试着按下方向右键
一坨js代码: function s_gi(un, pg, ss) { var c = "s.version='H.26';s.an=s_an;s.logDebug=function(m){ ...
- iOS之通过PaintCode快速实现交互动画的最方便方法 未解问题
需求: 问题: 源码百度云下载链接: http://pan.baidu.com/s/1o7r4hCm 密码: 8atd 其他学习链接:http://www.jianshu.com/p/90d6cd35 ...
随机推荐
- C#实现登录窗口(不用隐藏)
C#登录窗口的实现,特点就是不用隐藏,感兴趣的朋友不要错过 (1).在程序入口处,打开登录窗口 复制代码代码如下: static void Main() { Application.EnableV ...
- python编程语言 函数的形参
python编程语言 函数的形参的讲解: 我在交互模式中写了个函数: def adder(**args): sum=0 for x in args.keys(): sum+=args[x] retur ...
- 简单的php表单
表单的三种传递机制: $_GET:不安全,传递的参数会显示在url中. $_POST:相对安全,隐形传递. $_REQUEST:宽松的,包含所有 GET.POST.COOKIE 和 FILE 的数据. ...
- makefile懒人版(单个文件编译)
.PHONY:clean all CC=gcc CFLAGS=-Wall -g ###replace your bin BIN=1 2 3 4 all:$(BIN) %.o:%.c $(CC) $(C ...
- [DP] The 0-1 knapsack problem
Give a dynamic-programming solution to the 0-1 knapsack problem that runs in O(nW) time, where n is ...
- Spring MVC使用commons fileupload实现文件上传功能
通过Maven建立Spring MVC项目,引入了Spring相关jar依赖. 1.为了使用commons fileupload组件,需要在pom.xml中添加依赖: <properties&g ...
- code forces Jeff and Periods
/* * c.cpp * * Created on: 2013-10-7 * Author: wangzhu */ #include<cstdio> #include<iostrea ...
- table 表头固定
<html> <head> <title>Test</title> <style type="text/css"> .d ...
- Ubuntu下APACHE HTTPS安装和配置
http://blog.csdn.net/newjueqi/article/details/9789659
- BIOS与CMOS有什么区别
本文介绍BIOS与CMOS区别,BIOS是什么?BIOS全称Basic Input/Output System,所以BIOS本身个是系统简称,所以我们常说的BIOS芯片确切的讲是写有BIOS系统的芯片 ...