Contest2089,contest

來源:互聯網
上載者:User

Contest2089,contest

Problem E: SwipeTime Limit: 1 Sec  Memory Limit: 128 MB
Submit: 100  Solved: 15
[Submit][Status][Web Board]Description德魯伊在爐石傳說中是一個很穩定的職業,主流的卡組套路有咆哮德,城牆德以及讓人很無奈的疲勞德。然而,大部分的卡組總都包括“橫掃”這張德魯伊的職業法術卡。   我們假定戰場上的敵人數目不定,敵人的血量已知,我們想知道最少使用多少張“橫掃”能消滅戰場上所有敵人。Input第一行一個整數T( T<=100), 表示測試資料的組數。接下來有T組資料,每組資料第一行n ( n<=1000) ,表示戰場上敵人的數目第二行有n個數,表示每個敵人當前的血量 (數值不大於1000000)Output每組資料輸出一個整數,佔一行,表示消滅所有敵人所需的最少“橫掃”數目Sample Input
231 2 324 1 4 1 1
Sample Output
21
HINT

 

 

思路:每次攻擊最大的 ;最大的減3,放入排序,標準線(即全體減去的數)加1;
題目連結:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1648 
轉載請註明出處:尋找&星空の孩子
#include <iostream>#include <stdio.h>#include <string.h>#include <stack>#include <queue>#include <map>#include <set>#include <vector>#include <math.h>#include <bitset>#include <algorithm>#include <climits>using namespace std; #define LS 2*i#define RS 2*i+1#define UP(i,x,y) for(i=x;i<=y;i++)#define DOWN(i,x,y) for(i=x;i>=y;i--)#define MEM(a,x) memset(a,x,sizeof(a))#define W(a) while(a)#define gcd(a,b) __gcd(a,b)#define LL long long#define N 20005#define MOD 1000000007#define INF 0x3f3f3f3f#define EXP 1e-8 int a[1005],t,n; int main(){    int i,j,k;    scanf("%d",&t);    W(t--)    {        scanf("%d",&n);        UP(i,0,n-1)        {            scanf("%d",&a[i]);        }        if(n==1)        {            if(a[0]%4)                printf("%d\n",a[0]/4+1);            else                printf("%d\n",a[0]/4);            continue;        }        sort(a,a+n);        int ans = 0;        W(a[n-1]-ans>0)        {            ans++;            a[n-1]-=3;            for(i = n-2; i>=0; i--)            {                if(a[n-1]>a[i]||i==0)                {                    int tem = a[i+1];                    a[i+1] = a[n-1];                    for(j=n-1; j>=i+3; j--)                        a[j]=a[j-1];                    a[i+2] = tem;                    break;                }            }        }        printf("%d\n",ans);    }     return 0;} /**************************************************************    Problem: 1648    User: aking2015    Language: C++    Result: Accepted    Time:812 ms    Memory:1492 kb****************************************************************/

之後的明天再跟新。。。睡覺



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.