HDU 3296 & POJ 3138 Acm Team Section(数学)

题目链接:

HDU: http://acm.hdu.edu.cn/showproblem.php?pid=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 Description

The 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 competitive 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 participate in the on-site contest. It is really hard for the contest organizers to determine which teams should be allowed to participate. 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 participate in the on-site final contest.

Input

There 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 should not be processed by your program.

Output

For each test case, print the total number of teams which are allowed to participate 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 1
2 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 0
5 7
2 5
4 5
5 5
3 3
5 6
2 0
4 7 

0 0 0

Sample Output

Case 1: 10
Case 2: 9

Source

2006 Asia Regional Shanghai

题意:

ACM比赛由于比赛场地有限制不能容纳太多的队伍,所以现场赛之前会有网络赛,每个学校最多有三个队伍的名额能参加现场赛,且须满足三个条件!(在不超过三支队伍的情况下能满足几个条件就能有几支队伍参加),条件a:某学校的某支队伍解出了M道及其以上的题目;条件b:在WF排名前20的学校;条件c:今年学校举办过省赛;

思路:

很简单,先检查每所学校满足的条件b、c,满足几个条件就有几支队伍,然后再检查每所学校解题最多的队伍的题数是否大于等于M;

代码如下:

//#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;
}
时间: 2024-12-04 11:10:17

HDU 3296 & POJ 3138 Acm Team Section(数学)的相关文章

HDU 1087 &amp;&amp; POJ 2533(DP,最长上升子序列).

~~~~ 两道题的意思差不多,HDU上是求最长上升子序列的和,而POJ上就的是其长度. 貌似还有用二分写的nlogn的算法,不过这俩题n^2就可以过嘛.. ~~~~ 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 http://poj.org/problem?id=2533 ~~~~ HDU1087: #include<cstdio> #include<cstring> #include<algorithm> #

SDUT 2162-The Android University ACM Team Selection Contest(模拟)

The Android University ACM Team Selection Contest Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Now it's 20000 A.D., and the androids also participate in the ACM Inter-national Collegiate Programming Contest (ACM/ICPC). In order to selec

HDU 1102 &amp;&amp; POJ 2421 Constructing Roads (经典MST~Prim)

链接:http://poj.org/problem?id=2421  或   http://acm.hdu.edu.cn/showproblem.php?pid=1102 Problem Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We

POJ 3436 ACM Computer Factory(网络最大流)

http://poj.org/problem?id=3436 ACM Computer Factory Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5286   Accepted: 1813   Special Judge Description As you know, all the computers used for ACM contests must be identical, so the particip

Eight hdu 1043 poj 1077

Description The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all packed into a 4 by 4 frame with one tile mis

hdu 2844 poj 1742 Coins

hdu 2844 poj 1742 Coins 题目相同,但是时限不同,原本上面的多重背包我初始化为0,f[0] = 1;用位或进行优化,f[i]=1表示可以兑成i,0表示不能. 在poj上运行时间正好为时限3000ms....太慢了,hdu直接TLE(时限1s); 之 后发现其实并不是算法的问题,而是库函数的效率没有关注到.我是使用fill()按量初始化的,但是由于memset()可能是系统底层使用了四个字节拷 贝的函数(远比循环初始化快),效率要高得多..这就是为什么一直TLE的原因,fil

hdu 5171 GTY&#39;s birthday gift(数学,矩阵快速幂)

题意: 开始时集合中有n个数. 现在要进行k次操作. 每次操作:从集合中挑最大的两个数a,b进行相加,得到的数添加进集合中. 以此反复k次. 问最后集合中所有数的和是多少. (2≤n≤100000,1≤k≤1000000000) 思路: 写出来发现是要求Fibonaci的前n个数的和. Fibonaci是用矩阵快速幂求的,这个也可以. [Sn,Fn,Fn-1]=[某个矩阵]*[Sn-1,Fn-1,Fn-2] [S2,F2,F1]=[2,1,1] 然后写,,, 这个代码有些繁琐,应该把矩阵操作单独

Poj 3436 ACM Computer Factory (最大流)

题目链接: Poj 3436 ACM Computer Factory 题目描述: n个工厂,每个工厂能把电脑s态转化为d态,每个电脑有p个部件,问整个工厂系统在每个小时内最多能加工多少台电脑? 解题思路: 因为需要输出流水线要经过的工厂路径,如果要用电脑状态当做节点的话,就GG了.所以建图的时候要把工厂当做节点.对于节点i,能生产si电脑的节点可以进入节点i,能转化ei电脑的节点可以由i节点进入.要注意对于每一个节点要进行拆点,防止流量发生错误. 1 #include <queue> 2 #

HDU 1829 &amp;&amp; POJ 2492 A Bug&#39;s Life(种类并查集)

题目地址:HDU 1829     POJ 2492 这个题可以用两种方法做,第一眼看完题是觉得用dfs染色判断二分图.然后又写的刚学的种类并查集.原来并查集可以这样用,真是神奇.. dfs染色代码: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #incl