记录编号 |
119145 |
评测结果 |
AAAAAAAAAA |
题目名称 |
护卫队 |
最终得分 |
100 |
用户昵称 |
HouJikan |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.037 s |
提交时间 |
2014-09-11 14:28:49 |
内存使用 |
8.12 MiB |
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <ctime>
#include <functional>
#define pritnf printf
#define scafn scanf
#define For(i,j,k) for(int i=(j);i<=(k);(i)++)
using namespace std;
typedef long long LL;
typedef unsigned int Uint;
const int INF=0x7fffffff;
//==============struct declaration==============
//==============var declaration=================
const int MAXN=1010;
LL weight[MAXN],cost[MAXN][MAXN];
LL speed[MAXN];
double f[MAXN];
LL maxw;
int n;
double len;
//==============function declaration============
//==============main code=======================
int main()
{
string FileName="convoy";//程序名
string FloderName="COGS";//文件夹名
freopen((FileName+".in").c_str(),"r",stdin);
freopen((FileName+".out").c_str(),"w",stdout);
#ifdef DEBUG
system(("cp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\standard.cpp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\submit.txt").c_str());
clock_t Start_Time=clock();
#endif
scanf("%lld%lf%d",&maxw,&len,&n);
memset(weight,0,sizeof(weight));
For(i,1,n)
{
LL w;
scanf("%lld%lld",&w,&speed[i]);
weight[i]=weight[i-1]+w;
}
For(i,1,n)
{
LL mins=speed[i];
For(j,i,n)
{
mins=min(speed[j],mins);
cost[i][j]=mins;
}
}
f[1]=len/speed[1];
f[0]=0;
For(i,2,n)
{
f[i]=f[i-1]+len/speed[i];
for(int j=i;j>=1;j--)
{
if (weight[i]-weight[j-1]>maxw) break;
f[i]=min(f[i],f[j-1]+len/cost[j][i]);
}
}
pritnf("%.1lf\n",(f[n]*60));
#ifdef DEBUG
clock_t End_Time=clock();
cout<<endl<<endl<<"Time Used: "<<End_Time-Start_Time<<endl;
#endif
return 0;
}
//================fuction code====================