HDU 3296 & poj 3138 ACM Team Section (Mathematics)

Source: Internet
Author: User

Question link:

HDU: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 3296

Poj: http://poj.org/problem? Id = 3138

ACM Team Section Time Limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 159 accepted submission (s): 47


Problem descriptionthe ACM-ICPC brings together the top student programmers from all over the world, and provides them with opportunities to develop critical skills which will give them a given edge when they launch careers in information technology areas. more than 5,600 teams from 84 countries had competed in regional contests last year. an ever larger number of teams-more than 7,000 teams from different countries worldwide-have registered in this year's regional contests. however, due to the limited capacity of each site, only a small amount of the registered teams can be allowed to participates in the on-site contest. it is really hard for the contest organizers to determine which teams shocould be allowed to participant. one of the possible solutions is to hold a preliminary Internet contest before the on-site competition. the following part describes a simplified version of rules for team selection:

Up to three teams from each school can participate in the on-site contest, depending on how many following conditions the school in question meets:

A)
A team from this school has solved at least m problems in the preliminary contest;
B)
Some of the teams from this school ranked top 20 in previous world finals;
C)
This school has hosted a provincial contest this year.

Your task is to write a program to help the contest holders to calculate how many teams are allowed to participant in the on-site final contest.
Inputthere are multiple test cases in the input file. each test case starts with three integers S, T and M (1 <= S <= 100, 1 <= T <= 2000, 0 <= m <= 10 ), representing the number of schools, the number of teams participating in the preliminary contest, and the minimum number of problems which is required to be solved in order to enter the on-site competition, respectively.

Each of the following s lines consists of three integers ID, p and q, (1 <= ID <= s, 0 <= p, q <= 1 ), representing the ID of the school, whether this school satisfies Condition B), and whether this school satisfies condition C ).

The last part of each test case consists of T lines. there are two integers on each of the T lines, Sid and Tot (1 <= Sid <= s, 0 <= tot <= 10 ), meaning that a team from school Sid had solved tot problems in the preliminary contest.

Two consecutive test cases are separated by a blank line. S = 0, T = 0, m = 0 indicates the end of input and shocould not be processed by your program.
Outputfor each test case, print the total number of teams which are allowed to participant in the on-site competition on a separate line in the format as indicated in the sample output.
Sample Input
5 8 6 5 0 1 4 0 0 1 0 0 3 1 1 2 1 12 6 3 3 2 9 5 7 4 8 3 6 2 8 1 6 5 8 6 3 0 1 5 1 1 2 0 1 1 1 1 4 1 05 7 2 5 4 5 5 5 3 3 5 6 2 0 4 7 0 0 0
 
Sample output
Case 1: 10Case 2: 9
 
Source2006 Asia Regional Shanghai


Question:

Because the ACM Competition Venue is restricted and cannot accommodate too many teams, there will be a network competition before the competition. Each school can have a maximum of three teams to participate in the competition, three conditions must be met! (If no more than three teams can meet several conditions, several teams can participate). Condition A: A team in a school solves M-way and above-mentioned questions; condition B: the top 20 schools in WF; condition C: This year, the school held a provincial competition;

Ideas:

It is very easy to check the conditions B and c met by each school. There are several teams meeting the conditions, and then check whether the number of questions of the team with the most problems solved by each school is greater than or equal to m;


The Code is as follows:

//#pragma warning (disable:4786)#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <cstdlib>#include <climits>#include <ctype.h>#include <queue>#include <stack>#include <vector>#include <utility>#include <deque>#include <set>#include <map>#include <iostream>#include <algorithm>using namespace std;const double eps = 1e-9;//const double pi = atan(1.0)*4;const double pi = 3.1415926535897932384626;#define INF 1e18//typedef long long LL;//typedef __int64 LL;const int maxn = 2017;int main(){    int s[maxn], t[maxn];    int S, T, M;    int ID, P, Q;    int cas = 0;    while(scanf("%d%d%d",&S,&T,&M))    {        if(S==0 && T==0 && M==0)            break;        /*if(cas)            printf("\n");*/        memset(s,0,sizeof(s));        memset(t,0,sizeof(t));        int sum = 0;        for(int i = 1; i <= S; i++)        {            scanf("%d%d%d",&ID,&P,&Q);            sum+=P+Q;        }        int Sid, Tot;        for(int i = 1; i <= T; i++)        {            scanf("%d%d",&Sid,&Tot);            if(Tot >= M && t[Sid] == 0)            {                sum++;                t[Sid] = 1;            }        }        printf("Case %d: %d\n",++cas,sum);    }    return 0;}


HDU 3296 & poj 3138 ACM Team Section (Mathematics)

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.