码迷,mamicode.com
首页 > 其他好文 > 详细

P1916小书童--大战蚂蚁

时间:2019-02-20 20:04:17      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:http   names   href   ios   www   cst   space   targe   get   

链接

题解:(这里蚂蚁0血也算活...)

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int numt=0,n,m,k,w,r,a[100001],l=0,t=0;
void ta()
{
while(m>=k)
{numt++;//塔数
m-=k;
}
}
void px()//排序
{bool ok;
for(int i=n-1;i>=1;i--)
{
ok=true;
for(int j=1;j<=i;j++)
{
if(a[j]>a[j+1])
{swap(a[j],a[j+1]);
ok=false;
}
}
if(ok==true)break;
}
}
int ans()
{int y=numt*w;
for(int i=1;i<=n;i++)
{l++;//秒数
if(l<=r)a[i]-=y;
while(a[i]>=0&&l<=r)//若蚂蚁第一下没打死,继续打
{l++;a[i]-=y;
}
}
for(int i=1;i<=n;i++)
{if(a[i]>=0)t++;//若r秒后还活着,蛋糕数+1
}
return t;
}
int main()
{cin>>n>>m>>k>>w>>r;
for(int i=1;i<=n;i++)
cin>>a[i];
ta();
cout<<ans();
}

P1916小书童--大战蚂蚁

标签:http   names   href   ios   www   cst   space   targe   get   

原文地址:https://www.cnblogs.com/lcez56jsy/p/10408595.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!