E. Superhero Battle

 http://codeforces.com/contest/1141/problem/E

题意:有怪兽生命值H,可以进行多轮攻击,每一轮n分钟,每分钟改变怪兽生命值a[i],问是否能打倒它;

思路:求出轮数,再直接模拟;

总结:细节没注意到,要先看一轮是否达到,再看每轮sum是否大于零判断能否成功;写的时候调换了!!!

计算轮数要注意:最后一轮是在H要大于n之间的伤害最大值;是(H-Min)/sum,是要剩下大于Min的生命就直接模拟了!!;写的时候就最后模拟一轮是错误的!!

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;

#define sfi(i) scanf("%d",&i)
#define pri(i) printf("%d\n",i)
#define sff(i) scanf("%lf",&i)
#define ll long long
#define mem(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define eps 1e-6
#define PI acos(-1)
#define lowbit(x) ((x)&(-x))
#define zero(x) (((x)>0?(x):-(x))
inline void sc(T &ret)
{
    char c;
    ret = 0;
    while ((c = getchar()) < '0' || c > '9');
    while (c >= '0' && c <= '9')
    {
        ret = ret * 10 + (c - '0'), c = getchar();
    }
}

ll power(ll x,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return ans;
}

ll a[maxn];
int main()
{
    ll H;
    ll sum=0;
    int n;
    ll Min=INF;
    cin>>H>>n;
    for(int i=0;i>a[i];
        sum+=a[i];
        Min=min(Min,sum);
    }
    //cout<=0)
    {
        cout<<-1<

 

你可能感兴趣的:(E. Superhero Battle)