East China Jiaotong University 2015 ACM "double Base" program design contest 1003

Source: Internet
Author: User

Problem CTime limit:3000/1000ms (java/other) Memory limit:65535/32768k (Java/other) total submission (s): 225 Accep Ted Submission (s): 20font:times New Roman | Verdana | Georgiafont Size:←→problem Description "furnace Stone legend: Warcraft Heroes Biography" (Hearthstone:heroes of Warcraft, hereinafter referred to as the Furnace Stone legend) is a blizzard entertainment development of a set of card game ...
Simplified under the title: Two players A and B each have a number of cards (each card only attack and blood two properties, no additional attributes), each turn a card can only attack once,
and a card can only be attacked once, attack a card at the same time will be attacked by the attack card, the amount of blood to attack your card damage, when the blood volume is less than 1 o'clock, this card will be wiped out.
In the current round, a first attack, ask a attack, B on the left hand of the attack and the minimum amount of damage? Input the first line of T (T<=10), which represents the T-group data.
In each group of data, the first behavior n,m (0<n,m<8) represents N cards on field A, and M cards on the B field respectively.
In the next n rows, line I input aa[i],ab[i],aa[i] ab[i] respectively represents the attack and blood volume of the I card in field a.
In the next M line, line I input ba[i],bb[i],ba[i] bb[i] respectively represents the attack and blood volume of the I card on the B field.
(0<aa[i],ab[i],ba[i],bb[i]<=10) Output one row for each set of data, corresponding to the amount of damage left on the B field and the minimum value. Sample Input
11 32 18 27 26 2
Sample Output
13
Authormoonlike and real game is not the same, a each can only attack once and B each can only be attacked once. Then, the attackers in accordance with the low rank of attack to high order, the attack attacks high to low, the attack is equal, the blood is low to high order. And then we'll cycle.
#include <stdio.h>//#include <bits/stdc++.h> #include <string.h> #include <iostream> #include <math.h> #include <sstream> #include <set> #include <queue> #include <map> #include < vector> #include <algorithm> #include <limits.h> #define INF 0x3fffffff#define inf 0x3f3f3f3f#define Lson L,m,rt<<1#define Rson m+1,r,rt<<1|1#define LL long long#define ULL unsigned long longusing namespace Std;stru CT p{int x, y,} hehe[1000];struct c{int x, y,} he[1000];bool cmd1 (P a,p b) {return a.x<b.x;}    BOOL Cmd2 (C a,c b) {if (a.x==b.x) {return a.y<b.y;    } else {return a.x>b.x;    }}int Main () {int n,m;    int t;    int i,j;            while (cin>>t) {while (t--) {int ans=0;            cin>>n>>m;            for (i=0; i<n; i++) {cin>>hehe[i].x>>hehe[i].y;          } for (i=0; i<m; i++) {      cin>>he[i].x>>he[i].y;            } sort (HEHE,HEHE+N,CMD1);            Sort (HE,HE+M,CMD2); For (i=0, i<n; i++) {for (j=0; j<m; J + +) {if (HEHE[I].X&G                        t;=he[j].y&&he[j].x!=0) {he[j].x=0;                    Break            }}} for (i=0; i<m; i++) {ans+=he[i].x;        } cout<<ans<<endl; }} return 0;}

  

East China Jiaotong University 2015 ACM "double Base" program design contest 1003

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.