记录编号 |
201173 |
评测结果 |
AAAAAAAAAA |
题目名称 |
护卫队 |
最终得分 |
100 |
用户昵称 |
旧梦 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.022 s |
提交时间 |
2015-10-30 06:35:41 |
内存使用 |
0.41 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<algorithm>
#define LL long long
using namespace std;
const int maxn=1010;
int l,n,s[maxn];
LL w[maxn],rmq[maxn][15],sum[maxn],tot;
double dp[maxn];
void RMQ_init(){
for (int i=0;i<=n;++i) rmq[i][0]=s[i];
for (int j=1;(1<<j)<=n;++j)
for (int i=0;i+(1<<j)-1<=n;++i)
rmq[i][j]=min(rmq[i][j-1],rmq[i+(1<<j-1)][j-1]);
}
int RMQ(int l,int r){
int k=0;
while ((1<<k+1)<=r-l+1) k++;
return min(rmq[l][k],rmq[r-(1<<k)+1][k]);
}
int main(){
freopen("convoy.in","r",stdin);
freopen("convoy.out","w",stdout);
scanf("%lld%d%d",&tot,&l,&n);
for (int i=1;i<=n;++i){
scanf("%lld%d",&w[i],&s[i]);
sum[i]=sum[i-1]+w[i];
}
s[0]=1000000000;
RMQ_init();
for (int i=1;i<=n;++i) dp[i]=10000000000000;
dp[1]=(double)l/s[1]; dp[0]=0;
for (int i=2;i<=n;++i)
for (int j=i;j>=1;--j){
LL we=sum[i]-sum[j-1];
if (we>tot) break;
int tmp=RMQ(j,i);
double tim=(double)l/tmp;
dp[i]=min(dp[i],dp[j-1]+tim);
}
printf("%.1lf",dp[n]*60);
//system("pause");
}