A - George and Accommodation
Problem description
George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory.
George and Alex want to live in the same room. The dormitory has n rooms in total. At the moment the i-th room has pi people living in it and the room can accommodate qi people in total (pi ≤ qi). Your task is to count how many rooms has free place for both George and Alex.
Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of rooms.
The i-th of the next n lines contains two integers pi and qi (0 ≤ pi ≤ qi ≤ 100) — the number of people who already live in the i-th room and the room's capacity.
Output
Print a single integer — the number of rooms where George and Alex can move in.
Examples
Input
3
1 1
2 2
3 3
Output
0
Input
3
1 10
0 10
10 10
Output
2
解题思路:统计房间内剩余人数不小于2的房间总数(两个人住在同一间),水过!
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,p,q,num=;
cin>>n;
while(n--){
cin>>p>>q;
if(q-p>=)num++;
}
cout<<num<<endl;
return ;
}
A - George and Accommodation的更多相关文章
- cf467A George and Accommodation
A. George and Accommodation time limit per test 1 second memory limit per test 256 megabytes input s ...
- CF467 AB 水题
Codeforces Round #267 (Div. 2) (C和D的题解单独写:CF467C George and Job (DP) CF467D Fedor and Essay 建图DFS) C ...
- Codeforces Round #267 (Div. 2) A
题目: A. George and Accommodation time limit per test 1 second memory limit per test 256 megabytes inp ...
- codeforces467-A水题
题目链接:http://codeforces.com/problemset/problem/467/A A. George and Accommodation time limit per test ...
- CF467C George and Job (DP)
Codeforces Round #267 (Div. 2) C. George and Job time limit per test 1 second memory limit per test ...
- Codeforces Round #227 (Div. 2) E. George and Cards set内二分+树状数组
E. George and Cards George is a cat, so he loves playing very much. Vitaly put n cards in a row in ...
- Codeforces 467C George and Job(DP)
题目 Source http://codeforces.com/contest/467/problem/C Description The new ITone 6 has been released ...
- Codeforces Round #267 (Div. 2) C. George and Job DP
C. George and Job The new ITone 6 has been released ...
- HDU 4118 Holiday's Accommodation
Holiday's Accommodation Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 200000/200000 K (Jav ...
随机推荐
- ROS和OpenCV的对接cv_bridge
做一个诚实的ROS教程搬运工............................. 官网链接:http://wiki.ros.org/cv_bridge 一.Package Summary Rel ...
- weblogic详解
一.简介 WebLogic是美国Oracle公司出品的一个application server,确切的说是一个基于JAVAEE架构的中间件,WebLogic是用于开发.集成.部署和管理大型分布式Web ...
- javaee Properties键值对写入和读取方法
package Zjshuchu; import java.util.Properties; import java.util.Set; public class Demo03 { public st ...
- python学习笔记之小小购物车
#coding=utf-8 ''' Created on 2015-6-18 @author: 悦文 ''' def goods_list(): shangpin={"} print &qu ...
- eas之数据融合
1.如何进行自由融合自由融合无须指定区域,KDTable将根据指定的融合模式,融合相邻且值相等的单元.// 自由行融合table.getMergeManager().setMergeMode(KDTM ...
- 【剑指Offer】3、从尾到头打印链表
题目描述: 输入一个链表,按链表值从尾到头的顺序返回一个ArrayList. 解题思路: (三种方法:借助栈.递归.列表的首位插入) 从头到尾打印链表比较简单,从尾到头很自然的可以 ...
- MAC下redis的安装和配置
1.下载 打开官网:https://redis.io/ 选择下载你要的版本压缩包 2.安装 打开终端,cd - 将下载的压缩包拷贝到local目录下:sudo cp Downloads/redis-4 ...
- jQuery动态效果
1.一号店首页 2.淘宝网购物车
- xe7android调用webservice
1.如果用的roservice,那么用builder打开rodl然后直接生成wsdl保存: 2.由系统IDE的Component中调用import WSDL后save as. 3.调用代码: HTTP ...
- Mysql学习总结(12)——21分钟Mysql入门教程
21分钟 MySQL 入门教程 目录 一.MySQL的相关概念介绍 二.Windows下MySQL的配置 配置步骤 MySQL服务的启动.停止与卸载 三.MySQL脚本的基本组成 四.MySQL中的数 ...