Codeforces 321B Ciel and Duel

Source: Internet
Author: User

Test instructions: The other side has n cards, each card is either attack mode or defensive mode, you have M cards, are attack mode, each card has a value, you can do a bit of arbitrary

1) If you destroy the opponent's cards, then you can choose a card that has not been selected is the opponent suffered a card value attack.

2) You can choose a card that has not selected a value of x, attacking the opponent a card with the value y of the attack mode to cause (x-y) damage to the opponent and destroy the card x must be greater than or equal to Y

3) You can choose a card that has not selected a value of x, attacking the other side of a card with a defensive mode value of y does not cause harm to the other side, the opponent to eliminate the card. x must be greater than Y

Problem Solving Ideas: Violence + DP?

Problem Solving Code:

1 /************************************************************2 * Author:darkdream3 * Email: [Email protected]4 * Last modified:2015-03-31 11:105 * Filename:321b.cpp6 * Description:7  * *********************************************************/8 //File name:321b.cpp9 //Author:darkdreamTen //Created time:2015 March 31 Tuesday 09:34 01 seconds One  A#include <vector> -#include <list> -#include <map> the#include <Set> -#include <deque> -#include <stack> -#include <bitset> +#include <algorithm> -#include <functional> +#include <numeric> A#include <utility> at#include <sstream> -#include <iostream> -#include <iomanip> -#include <cstdio> -#include <cmath> -#include <cstdlib> in#include <cstring> -#include <ctime> to #defineLL Long Long +  - using namespacestd; the intN, M; * intatk[ the]; $ intatkn;Panax Notoginseng intdef[ the]; - intdefn; the intmatk[ the]; + inttatk[ the]; A inttatkn; the Charstr[ -]; + intMX; - intSolveintk) $ { $     intAns =0 ; -      for(inti =1; i<= K;i + +) -     { the         if(Matk[i] >= atk[k-i+1]) -         {WuyiAns + = matk[i]-atk[k-i+1]; the}Else{ -          return-1; Wu         } -     } AboutMX =Max (Mx,ans); $     returnans; - } - intcmpintAintb) - { A    returnA >b; + } themultiset<int>num; - intMain () { $scanf"%d%d",&n,&m);  the     intta; the      for(inti =1; I <= N;i + +) the     { thescanf"%s", str); -scanf"%d",&ta); in         the        if(str[0] =='D') the        { AboutDefn + + ;  theDEF[DEFN] =Ta;  the        } the        Else{ +ATKN + + ;  -ATK[ATKN] =ta; the        }Bayi     } the      for(inti =1; I <= M;i + +) the     { -scanf"%d",&matk[i]); - Num.insert (Matk[i]); the       //printf ("%d%d\n", m,num.size ()); the     } theSort (atk+1, atk+1+atkn); theSort (matk+1, matk+m+1, CMP); -      for(inti =1; I <= min (atkn,m); i++) the     { the solve (i); the     }94     if(M > atkn +defn) the     { the         Set<int>:: iterator tt; the         intOK =1; 98          for(inti =1; I <= defn; i + +) About         { -tt =Num.upper_bound (Def[i]);101             if(TT = =num.end ())102             {103OK =0 ;104                  Break; the}Else{106 num.erase (TT);107             }108         }109         if(OK = =1) the         {111m =0 ; thememset (MATK,0,sizeof(MATK));113              for(TT = Num.begin (); TT! = Num.end (); TT + +) the             { theM + + ; theMATK[M] = *tt;117             }118Sort (matk+1, matk+m+1, CMP);119             inthehe =solve (ATKN); -             if(Hehe! =-1 )121             {122                 for(inti = atkn+1; I <= M;i + +)123                {124hehe + =Matk[i]; the                }126MX =Max (HEHE,MX);127             } -         }129     } theprintf"%d\n", MX);131 return 0; the}
View Code

Codeforces 321B Ciel and Duel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.