记录编号 |
46226 |
评测结果 |
AAAAAAAAAAAA |
题目名称 |
[网络流24题] 餐巾 |
最终得分 |
100 |
用户昵称 |
Truth.Cirno |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.156 s |
提交时间 |
2012-10-27 10:42:29 |
内存使用 |
2.89 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(void)
{
freopen("napkin.in","r",stdin);
freopen("napkin.out","w",stdout);
int n,newcost,fasttime,fastcost,slowtime,slowcost,need[210]={0};
int newnow,i,j,maxneed=0,totalneed=0,mincost,costnow;
int avanum,neednow,slownum,fastnum,dirtynum[210]={0};
bool fin=false;
cin>>n;
for (i=1;i<=n;i++)
{
cin>>need[i];
totalneed+=need[i];
if (maxneed<need[i])
maxneed=need[i];
}
cin>>newcost>>fasttime>>fastcost>>slowtime>>slowcost;
mincost=newcost*totalneed;
for (newnow=totalneed-1;newnow>=maxneed;newnow--)
{
avanum=newnow;
costnow=newcost*newnow;
for (i=1;i<=n;i++)
{
if (avanum>=need[i])
{
avanum-=need[i];
dirtynum[i]=need[i];
}
else
{
neednow=need[i]-avanum;
avanum=0;
slownum=0;
fastnum=0;
/*neednow*/
for (j=1;j<=i-slowtime;j++)
{
if (slownum<neednow)
{
slownum+=dirtynum[j];
dirtynum[j]=0;
if (slownum>=neednow)
{
dirtynum[j]=slownum-neednow;
slownum=neednow;
break;
}
}
}
neednow-=slownum;
if (neednow)
{
for (j=i-fasttime;j>=1;j--)
{
if (fastnum<neednow)
{
fastnum+=dirtynum[j];
dirtynum[j]=0;
if (fastnum>=neednow)
{
dirtynum[j]=fastnum-neednow;
fastnum=neednow;
break;
}
}
}
}
neednow-=fastnum;
if (neednow)
{
fin=true;
break;
}
costnow+=slownum*slowcost+fastnum*fastcost;
dirtynum[i]=need[i];
}
}
if (fin)
{
break;
}
else
{
if (mincost>costnow)
mincost=costnow;
}
}
cout<<mincost<<endl;
return(0);
}