1.Link:

http://poj.org/problem?id=3117

2.Content:

World Cup
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 8778   Accepted: 4406

Description

A World Cup of association football is being held with teams from around the world. The standing is based on the number of points won by the teams, and the distribution of points is done the usual way. That is, when a teams wins a match, it receives 3 points; if the match ends in a draw, both teams receive 1 point; and the loser doesn’t receive any points.

Given the current standing of the teams and the number of teams participating in the World Cup, your task is to determine how many matches ended in a draw till the moment.

Input

The input contains several test cases. The first line of a test case contains two integers T and N, indicating respectively the number of participating teams (0 ≤ T ≤ 200) and the number of played matches (0 ≤N ≤ 10000). Each one of the T lines below contains the name of the team (a string of at most 10 letter and digits), followed by a whitespace, then the number of points that the team obtained till the moment. The end of input is indicated by T = 0.

Output

For each one of the test cases, your program should print a single line containing an integer, representing the quantity of matches that ended in a draw till the moment.

Sample Input

3 3
Brasil 3
Australia 3
Croacia 3
3 3
Brasil 5
Japao 1
Australia 1
0 0

Sample Output

0
2

Source

South America 2006, Brazil Subregion

3.Method:

4.Code:

 #include <iostream>
#include <cstdio> using namespace std; int main()
{
int i;
int t,n;
int num,a;
char ch[];
while((cin>>t>>n)&&(t!=||n!=))
{
num=;
for(i=;i<t;i++)
{
scanf("%s",ch);
cin>>a;
num+=a;
}
cout<<(*n-num)<<endl;
}
//system("pause");
return ;
}

5.Reference:

Poj 3117 World Cup的更多相关文章

  1. Poj 1953 World Cup Noise之解题报告

    World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16369   Accepted: 8095 ...

  2. poj - 1953 - World Cup Noise(dp)

    题意:n位长的01序列(0 < n < 45),但不能出现连续的两个1,问序列有多少种. 题目链接:id=1953" target="_blank">h ...

  3. POJ 1953 World Cup Noise

    World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14397   Accepted: 7129 ...

  4. poj 1953 World Cup Noise (dp)

    World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16774   Accepted: 8243 ...

  5. POJ 1953 World Cup Noise(递推)

    https://vjudge.net/problem/POJ-1953 题意:输入一个n,这n位数只由0和1组成,并且不能两个1相邻.计算共有多少种排列方法. 思路:递推题. 首先a[1]=2,a[2 ...

  6. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  7. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  8. poj分类

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

  9. poj 题目分类(1)

    poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...

随机推荐

  1. [Javascript] Either Functor

    Either Functor: // API Right(val) // resolve the value Left(val) // return error message Examples: m ...

  2. OpenStack Magnum 项目简单介绍

    背景 Magnum 项目是 2014 年 11 月增加 OpenStack 的年轻项目,由 Rackspace主导发起,其定位是提供容器即服务(Container as a Service)的 API ...

  3. 设计一个算法,输出从u到v的全部最短路径(採用邻接表存储)

    思想:用path数组存放路径(初始为空),d表示路径长度(初始为-1),查找从顶点u到v的最短路径过程如图所看到的: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5u ...

  4. mysql 5.6 binlog组提交1

    [MySQL 5.6] MySQL 5.6 group commit 性能测试及内部实现流程   尽管Mariadb以及Facebook在long long time ago就fix掉了这个臭名昭著的 ...

  5. MySQL_前缀索引_建立

    -- 查看出现频率select count(*) as cnt,cityfrom sakila.city_demo group by city order by cnt desc limit 10; ...

  6. 琐碎-hadoop1.X和2.X的区别

    1.  jobtracker做了分离,分成了resourceManager和nodemanager: 2.  MR变成了和HBase和Hive等一样的yarn上面的一个应用: 3.  1.x的默认块大 ...

  7. 易维清使用技巧:CHM编辑利器

    易维清源代码生成软件不但是一款专业的管理信息系统源代码生成器,其附带的编辑帮助信息功能更是CHM编辑利器.而且,免费试用版中的这个功能完全没有削减的哦,不花钱就可以帮你轻松编辑生成完美的CHM,官方下 ...

  8. 给jdk写注释系列之jdk1.6容器(9)-Strategy设计模式之Comparable&Comparator接口

    前面我们说TreeMap和TreeSet都是有顺序的集合,而顺序的维持是要靠一个比较器Comparator或者map的key实现Comparable接口.      既然说到排序,首先我们不用去关心什 ...

  9. [转]每次打开IE9就会跳出管理加载项的窗口

    当您打开IE9就跳出管理加载项的窗口,这一般是由于使用优化软件对系统进行优化清理后导致了注册表的错误.上次我们就为大家介绍了关于IE9启动后自动弹出管理加载项窗口的问题,这两个问题非常类似,引发问题的 ...

  10. [改善Java代码]边界,边界,还是边界

    建议24:边界,边界,还是边界 import java.util.Scanner; public class Client { //一个会员拥有产品的最大数量 public final static ...