NBUT 1455 Malphite (模拟水题)

  • [1455] Malphite

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Granite Shield(花岗岩护盾) - Malphite is shielded by a layer of rock which absorbs damage up to 10% of his maximum Health.

     

    If Malphite has not been hit for 10 seconds, this effect recharges.

     

    To simply this problem all the calculation will in integer not decimal. For example, 15 / 10is 1 not 1.5.

  • 输入
  • There are muti-case.
    For each case, the first line contain two integer M (0 < m < 10000), N (0 < N < 10000).
    M means to the maximum health, N is the time Malphite is attacked.
    The following N lines, each line contain two integer Ti ( 0 ≤ Ti ≤ 10000), Di (0 < Di ≤ 100), stands for the attack time and the damage.
  • 输出
  • For each test case, output the Malphite's final health value, if Malphite can't afford all these damage, print "I'm dead!".
  • 样例输入
  • 10 2
    1 3
    4 5
    10 2
    1 3
    11 5
    10 1
    11 11
  • 样例输出
  • 3
    4
    I'm dead!
  • 提示
  • 来源
  • Monkeyde17

题意:熔岩巨兽-墨菲特有个被动技能就是只要自己10秒不被攻击,就有一个盾,盾能承受的最大伤害是生命值的10%,给出被攻击的时间和伤害,求最后情况。

分析:模拟,按照时间先后给造成的伤害排个序,然后首先判断盾有没有更新,有更行的话盾的值就是生命值的10%,没有更新的话,就是上次盾剩下的值继续减。

 

#pragma comprint(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<stdlib.h>
#include<time.h>
#include<algorithm>
#define LL __int64
#define FIN freopen("in.txt","r",stdin)
using namespace std;
const int MAXN=10000+5;
struct node
{
    int t,atk;
    bool operator<(const node A)const
    {
        if(t==A.t) return atk>A.atk;
        return t<A.t;
    }
}a[MAXN];
int main()
{
    //FIN;
    int n,m;
    while(scanf("%d %d",&n,&m)!=EOF)
    {
        for(int i=0;i<m;i++)
            scanf("%d %d",&a[i].t,&a[i].atk);

        sort(a,a+m);
        //for(int i=0;i<m;i++) printf("%d %d\n",a[i].t,a[i].atk);
        bool flag=false;
        int pre=0;
        int dun=n/10;
        int h=n;

        dun=dun-a[0].atk;
        if(dun<=0) {h=h+dun;dun=0;}
        pre=a[0].t;
        if(h<=0){printf("I'm dead!\n");continue;}

        for(int i=1;i<m;i++)
        {
            if(a[i].t-pre>=10) dun=n/10-a[i].atk;
            else dun=dun-a[i].atk;
            
            if(dun<=0) {h=h+dun;dun=0;}
            pre=a[i].t;
            if(h<=0) {flag=true;break;}
        }
        if(flag) printf("I'm dead!\n");
        else printf("%d\n",h);
    }
    return 0;
}
View Code

 

posted @ 2015-08-22 01:22  Cliff Chen  阅读(190)  评论(0编辑  收藏  举报